finding application directory

  • Thread starter Thread starter vadim
  • Start date Start date
V

vadim

Hi,

How can I find the directory where my application resides or where it was
launched from?
There are .Net functions that give current directory but not the application
directory.

Thank you

Vadim
 
* "vadim said:
How can I find the directory where my application resides or where it was
launched from?
There are .Net functions that give current directory but not the application
directory.

\\\
Imports System.IO
Imports System.Reflection
..
..
..
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 
Hi Herfried. I would have used the following.

string myDir = System.IO.Directory.GetCurrentDirectory();

Or is there a reason to avoid it and use you method instead?
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
Herfried K. Wagner said:
* "vadim said:
How can I find the directory where my application resides or where it was
launched from?
There are .Net functions that give current directory but not the application
directory.

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

If you are building WindowsForms application you can use Application class
for getting that info
Application.StartupPath is what you are after, I believe.
 
* "Mark Broadbent said:
string myDir = System.IO.Directory.GetCurrentDirectory();

Or is there a reason to avoid it and use you method instead?

The current directory can be changed. 'Application.StartupPath' is more
appropriate, IMO, but as far as I know, my solution is the most "stable"
;-).
 
Thank you for your answers, guys.
Application.StartupPath is probably what I was looking for.

Stoitcho Goutsev (100) said:
Hi vadim,

If you are building WindowsForms application you can use Application class
for getting that info
Application.StartupPath is what you are after, I believe.

--
HTH
Stoitcho Goutsev (100) [C# MVP]


vadim said:
Hi,

How can I find the directory where my application resides or where it was
launched from?
There are .Net functions that give current directory but not the application
directory.

Thank you

Vadim
 
Back
Top