Solved

getting the full path of my vb.net app

Posted on 2010-08-24
8
573 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need help converting a bitmap to an image in VB.Net 1 32
How do you do a one to many list in .NET CORE? 2 24
start a process from a service 3 21
.NET 2008 VB and C# 6 27
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

786 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