Lingyong Wang
Lingyong Wang

Reputation: 31

c# how to get the install path of my program?

guys.
In my program, i need to execute a kmlsample.exe in CMD, right now, it stays at my solution folder.
i can just do

string command = "\"C:\\Documents and Settings\\Bruce\\My Documents\\Visual Studio    2008\\Projects\\KMeans\\KMeans\\kmlsample.exe"  

but when i let the user to install my program, how can i know the path of my program got installed,
in order to execute the exe file.

thank you

Upvotes: 2

Views: 5255

Answers (2)

Brent Stewart
Brent Stewart

Reputation: 1840

You can get the executing assembly's location from

System.Reflection.Assembly.GetExecutingAssembly().Location

Upvotes: 2

asawyer
asawyer

Reputation: 17818

This might be what your looking for.

http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx

Edit - You need to run this after the install inside your main program right? This won't work if you need to run something during the install.

Upvotes: 4

Related Questions