Solved

getting the full path of my vb.net app

Posted on 2010-08-24
8
593 Views
Last Modified: 2012-05-10
Hi,

I'm trying to map a path to my file, it is looking for the bin folder of my app which is fine but at the moment I have to put the really long directory structure before the file name.

How can I say some sort of system.app path:
xsltrans.Transform("C:\Documents and Settings\someuser\My Documents\Visual Studio 2008\Projects\DespatchNotePrinting\DespatchNotePrinting\Test.xml", "C:\Documents and Settings\someuser\My Documents\Visual Studio 2008\Projects\DespatchNotePrinting\DespatchNotePrinting\Results.html") ', resolver)
0
Comment
Question by:scm0sml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 7

Expert Comment

by:Alex_W
ID: 33509488
System.AppDomain.CurrentDomain.BaseDirectory() & "FileName.xxx"
0
 
LVL 7

Expert Comment

by:Alex_W
ID: 33509509
Or
Application.StartupPath + "\File.xxx"
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 33509519
The installation path can be found with My.Application.Info.DirectoryPath

Wayne
0
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 

Author Comment

by:scm0sml
ID: 33509547
ok i think i have given you the worng info. i dont want to be hitting th bin folder i dont think.

Just the root level.
Basically I have an xslt file at the same level as all my other pages in the app so want to hit this directory...?

Thanks
0
 
LVL 7

Expert Comment

by:Alex_W
ID: 33509610
Oh, Application.StartupPath will pickup the same location as the .exe.  I suppose you could take a substring of the resulting location and remove "\bin\Debug" from the end but this will get confused when running the .exe from another location once deployed.
0
 

Author Comment

by:scm0sml
ID: 33509701
why doesnt a copy of the xslt file get put in the same place then?

I need this to be able to run when deployed.....?
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 33509770
Personally I wouldn't put the XSLT file in the same folder as the EXE. I would put it in the Application Data path.

My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData
http://msdn.microsoft.com/en-us/library/2zbz2kdb%28VS.90%29.aspx

Wayne
0
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 500 total points
ID: 33510344
"my other pages in the app ", what kind of app is this?  I think we've all been assuming it's windows not web, please correct if that's not right.

If windows, keep in mind that when its deployed, the ONLY content you'll have available is what's in the bin folder, that will be the root (apart from anything you put into appData as webtubbs has said).

So you just need to get the xslt into the bin folder:
Right click the file, go to properties, and change the "Copy To Output Directory" from "Do not copy" to "Copy if newer".
Then reference it with Application.StartupPath as Alex said.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question