Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

getting the full path of my vb.net app

Posted on 2010-08-24
8
Medium Priority
?
604 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 48

Expert Comment

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

Wayne
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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 48

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

971 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