471,627 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Can I find the installation dorectory from code

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."
--
Dave
Jan 4 '06 #1
5 2658

Dave wrote:
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

Jan 4 '06 #2
How about Assembly.GetEntryAssembly().CodeBase or one of the other
properties.

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
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."
--
Dave

Jan 4 '06 #3
Found it - Application.ExecutablePath.
Shouldn't be so eager to post
--
Dave
"Dave" wrote:
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."
--
Dave

Jan 4 '06 #4

Dave wrote:
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

Jan 4 '06 #5
Not to leave out System.Environment.CurrentDirectory. They all have slightly
different effects and applications.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dave" wrote:
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."
--
Dave

Jan 5 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Paul Rubin | last post: by
4 posts views Thread by Bill Murray | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.