Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

is there a way to find out within a C# program, from which installation directory it was loaded. The Environment just gives the current directory but not the installation directory.

Any hint is very much appreciated.

Wolfgang
Posted

Try this:
C#
string path = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

Hope this helps.
 
Share this answer
 
Hello

great, it works perfect.

Wolfgang
 
Share this answer
 
Comments
Thomas Daniels 4-Nov-12 10:33am    
Thanks!

But if you've a comment to an answer, please use the 'Have a Question or Comment?' button to post a comment to an answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900