Fuzzyketchup Fuzzyketchup - 2 months ago 21
C# Question

C# Process.Start Path

I currently have a functioning program that simply launches a separate .exe file by clicking a button. The installer I've created asks where they want to install which by default is in fodler

C:\Program Files\PRHA
.

The code that launches the programs looks like this

private void ivClick(object sender, RoutedEventArgs e)
{
Process.Start("C:/Program Files/PRHA/IV/IV.exe");
}


How can I have
Process.Start
find the path of the running application, so if the user decides to install in another directory,
Process.Start
will still work.

Answer

In the event that you just want to get the path of the running application to launch a secondary application (in the same directory) you should be able to use:

System.Reflection.Assembly.GetExecutingAssembly().Location

Reference:
http://msdn.microsoft.com/en-us/library/aa457089.aspx
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.location(v=vs.110).aspx

Comments