App.Path replacement

Z

z. f.

Hi,

in VB6 i use App.Path to determine the path my executable run from.
what is the VB.NET / framework replacement fot that?

TIA, z.
 
S

Shiva

Application.StartupPath

Hi,

in VB6 i use App.Path to determine the path my executable run from.
what is the VB.NET / framework replacement fot that?

TIA, z.
 
I

Imran Koradia

Application.ExecutablePath (with filename) or
Application.StartupPath(without filename). I believe StartupPath directly
corresponds to VB6's App.Path.

hope that helps..
Imran.
 
H

Herfried K. Wagner [MVP]

z. f. said:
in VB6 i use App.Path to determine the path my executable run from.
what is the VB.NET / framework replacement fot that?

'Application.StartupPath', or more general (can be used in DLL projects
too):

\\\
Imports System.IO
Imports System.Reflection
..
..
..
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 
C

Cor Ligthert

Herfried,
Nice done really an addition.
Seems that people think this is sarcastic, it is not, we normally see only
the Application.StartupPath I find this a nice addition to that.

Cor
 
H

Herfried K. Wagner [MVP]

Cor,

Cor Ligthert said:
Seems that people think this is sarcastic, it is not, we
normally see only the Application.StartupPath I find this
a nice addition to that.

:)
 
S

Stefan Simek

What about AppDomain.CurrentDomain.BasePath?

Herfried K. Wagner said:
z. f. said:
in VB6 i use App.Path to determine the path my executable run from.
what is the VB.NET / framework replacement fot that?

'Application.StartupPath', or more general (can be used in DLL projects
too):

\\\
Imports System.IO
Imports System.Reflection
.
.
.
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 
S

Stefan Simek

Herfried K. Wagner said:
What if you set up more than one appdomain in your application?

If you don't I guess it's usable.

If you do, it depends what exactly do you need to use.
 
Z

z. f.

if your code is running inside a DLL then code:
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
will not give the same results as
'Application.StartupPath'
since it will return the DLL location while the other will give the
executable location, which i need.


Herfried K. Wagner said:
z. f. said:
in VB6 i use App.Path to determine the path my executable run from.
what is the VB.NET / framework replacement fot that?

'Application.StartupPath', or more general (can be used in DLL projects
too):

\\\
Imports System.IO
Imports System.Reflection
.
.
.
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 
S

Stefan Simek

Then replace GetExecutingAssembly() with GetEntryAssembly() ;)

HTH,
Stefan

z. f. said:
if your code is running inside a DLL then code:
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
will not give the same results as
'Application.StartupPath'
since it will return the DLL location while the other will give the
executable location, which i need.


Herfried K. Wagner said:
z. f. said:
in VB6 i use App.Path to determine the path my executable run from.
what is the VB.NET / framework replacement fot that?

'Application.StartupPath', or more general (can be used in DLL projects
too):

\\\
Imports System.IO
Imports System.Reflection
.
.
.
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top