Can I find the installation dorectory from code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want my app to create a file in a convenient exisiting folder. The logical
place to craete it would be the application's installation folder. Is there
any way that an application can get the path of its own installation - or,
equivelantly, the path from which it was run. (I was going to use
Environment.CommandLine, which includes the program name, but the help states
"The program name can, but is not required to, include path information."
 
How about Assembly.GetEntryAssembly().CodeBase or one of the other
properties.
 
Dave said:
I want my app to create a file in a convenient exisiting folder. The logical
place to craete it would be the application's installation folder. Is there
any way that an application can get the path of its own installation - or,
equivelantly, the path from which it was run. (I was going to use
Environment.CommandLine, which includes the program name, but the help states
"The program name can, but is not required to, include path information."

Application.StartupPath will do what you want.

Matt
 
Dave said:
Found it - Application.ExecutablePath.
Shouldn't be so eager to post

StartupPath is easier, you don't have to remove the executable name
that way.

:)

Matt
 
Not to leave out System.Environment.CurrentDirectory. They all have slightly
different effects and applications.
Peter
 
Back
Top