views:

57

answers:

4

I'm trying to start an application programatically, but it always runs it in the folder of my application... For example:

If my app is located in C:\MyApp\myapp.exe and the other app is in C:\OtherApp\otherapp.exe, how can I start the other app in the folder in which it resides, rather than in the folder where my app resides?

Here is how I start the other app:

private void StartApp(OtherApp application)
{
    Process process = new Process();
    process.StartInfo.FileName = application.FileName;
    process.StartInfo.Arguments = application.AppName;
    process.Start();
}
+3  A: 

I guess you mean ProcessStartInfo.WorkingDirectory Property

Giorgi
@Giorgi, that's what I needed... I was looking for a Directory property, but I should have been looking for a WorkingDirectory property! Thanks :).
Lirik
+1  A: 

Just set the WorkDirectory property.

process.StartInfo.WorkingDirectory = Path.GetDirectoryName(application.Filename);
GenericTypeTea
+1  A: 

Use process.StartInfo.WorkingDirectory = pathToTheFolder;.

Femaref