App.Path in VB.NET
Hi all,
I know VB.NET does not support App.Path, so i found this bit of code:
Public Function App_Path() As String
Return System.AppDomain.CurrentDomain.BaseDirectory()
End Function
its instructions say copy and Unlike app.path in vb6, this includes the the "\" at the end of the value. :confused:
I dont understand what it mean by "\", can anyone advise?
[416 byte] By [
mp_direct] at [2007-11-11 7:18:15]

# 1 Re: App.Path in VB.NET
In VB6, App.Path only includes a backslash (\) at the end of the path if the app is running in the root directory of the drive. That is, if the app is running in the root directory of drive C:, App.Path returns "C:\". If, on the other hand, the app is running in C:\Program Files\My App, App.Path returns "C:\Program Files\My App" (no backslash at the end). Because of this discrepancy, you need to check for the presence of a trailing backslash before appending a file name to the path.
Your VB.NET App_Path function returns a trailing backslash in all cases -- "C:\" or "C:\Program Files\My App\" -- so you may simply append a file name without checking for a backslash.
# 2 Re: App.Path in VB.NET
The "real" replacement for App.Path is the following:
Application.ExecutablePath
VB.NET also offers a second option that returns the working directory at the start of the application:
Application.StartupPath
Going through the AppDomain works most of the time, but an AppDomain and an Application are not the same, and in some cases, the code you used could link to something else than the directory you are looking for.