-1

I'm trying to set my application to launch DF.exe. If I double click the exe (running it normally), it launches fine, however if I try to do so from the launcher I'm creating, it can't find the files necessary for it to run, leading me to believe that it's finding the exe and running it using the wrong directory.

This is what my code looks like:

string DFPath = "0.47.04\\DF.exe";
System.Diagnostics.Process.Start(@DFPath);
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

I believe that the issue is due to "Working Directory".

When you run an application from Windows Explorer (double-clicking it) then it is executing in the directory it lives it (since that's where you are).

From your code, it looks like you're searching for the EXE in a different directory, which means that your current Working Directory is somewhere different.

Either, change the working directory of your application or pass in the working directory to Process.Start.

System.Environment.CurrentDirectory = "<path to where EXE is>";
Process.Start(@DFPath);

Or:

var processStart = new ProcessStartInfo
{
     Filename = "DF.exe";
     WorkingDirectory = "<path of where EXE is>";
}
James Woodall
  • 725
  • 7
  • 15