Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 App.Path Equivalent

Status
Not open for further replies.

Mongr1l

Programmer
Mar 6, 2006
179
US
Anyone know what the VB.Net equivalent is?

- mongril
 
Sure thing:

Code:
    [COLOR=blue]Public[/color] [COLOR=blue]Function[/color] Path() [COLOR=blue]As[/color] [COLOR=blue]String[/color]
        [COLOR=green]'App.Path[/color]
        [COLOR=blue]Return[/color] System.AppDomain.CurrentDomain.BaseDirectory
    [COLOR=blue]End[/color] [COLOR=blue]Function[/color]
 
Oh, and you'll want make sure you have the correct import as well:

Code:
[COLOR=blue]Imports[/color] System.Reflection.Assembly
 
Either works, but there is a difference.

The BaseDirectory way gives you the path along with the backslash at the end, StartupPath gives you the path without the backslash.

Example:

BaseDirectory - C:\Program Files\My Company\Program\
StartupPath - C:\Program Files\My Company\Program
 
Interesting ThatRickGuy - you can tell I don't use remoting or cross-domain apps.

Mongr1l - CurDir() (I haven't really used it, so forgive me if I get this wrong), I believe retrieves the Current working directory - which may or may not be your application directory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top