Question Finding the path to your application

Wibs

Member
Joined
Jan 16, 2009
Messages
20
Programming Experience
Beginner
Hi,

Imagine a small application, myApp.exe, that contains one button and a textbox. You drop the application into any folder anywhere on your hard drive, run it, click the button and the textbox says something like this:

The full path to the location of this application is:
C:\Documents and Settings\Colin\My Documents\Downloads\myApp.exe

How can the application discover the path to its own location?

TIA

Wibs
 
Discover the "My" object. Type "My." and you get all kinds of intuitive shortcuts to common tasks and info. Since you're interested in "application" try "My.Application.", it shouldn't take you long time to find the directory path info.
VB.NET:
My.Application.Info.DirectoryPath
The Application class is also something you find if you search help for "application"
VB.NET:
Application.StartupPath
Easy, isn't it?
 
Hi :)

Yes, easy when you know what to search for. Unfortunately most search boxes do not let you search for multiple terms, such as 'Application' & 'Path'. Typing either of these two terms produced 100s of hits.

Many thanks, that command is precisely what I was looking for.

Wibs
 
Hi :)

Yes, easy when you know what to search for. Unfortunately most search boxes do not let you search for multiple terms, such as 'Application' & 'Path'. Typing either of these two terms produced 100s of hits.

Many thanks, that command is precisely what I was looking for.

Wibs
I went to the MSDN web site and typed application path into the search box and refined the results by .NET Development. The documentation for the Application.ExecutablePath property was the seventh result. It also shows this much of the topic itself:
Gets the path for the executable file that started the application, including the executable name.
The documentation for the Application.StartupPath property was also on the first page of results and showed this much of the topic itself:
Gets the path for the executable file that started the application, not including the executable name.
 
I guess that the biggest problem with VB (I am using Visual Basic Express 2005) is not the lack of info, it is finding it.

When I downloaded VB2005E I chose the option to download the MSDN library as well (so I wouldn't have to keep going to the website to find info), which I can now access via the VB2005E Help menu. However, typing 'Application' into the search box brings up 100s of references that start with that word, and there is no further filtering allowed (that I have been able to find), so you are forced to read through 100s of entries until you find one that sounds like what you want.

Of course, now that I have been told of two commands:

Application.StartupPath
My.Application.Info.DirectoryPath

I can scroll down and find them, but I would never have found them using search. Typing 'Path' only finds all commands that start with that word, it does not find it within words such as 'StartupPath' or 'DirectoryPath' unless you know those compound words already, and as it was a 'Path' that I was trying to find I concentrated my searching on that word, but all to no avail.

Anyways, thanks for the tips on searching though.

Wibs
 
Back
Top