Can I find the installation dorectory from code

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."
 
P

Peter Rilling

How about Assembly.GetEntryAssembly().CodeBase or one of the other
properties.
 
M

Matt

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
 
M

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
 
G

Guest

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

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