Solved

getting the full path of my vb.net app

Posted on 2010-08-24
8
555 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
  • 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
 

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 22

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VB.net PaintEventArgs Handling. 10 27
Expando 4 33
.Net application crashing 6 20
Create XML 5 31
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now