ThisGuy
ThisGuy

Reputation: 5

C# Process.Start() - target app can't find file

I'm trying to start application "GA.exe", but on start it's taking data from file "acc.txt". If I start it normallly (via double click :-)) it works, but if I use code below it say "Can't find acc.txt".

My first idea:

Process.Start(pathToGA.exe);

Second idea:

ProcessStartInfo pinfo = new ProcessStartInfo()
                {
                    Arguments = FolderWithGA.exePath,
                    FileName = pathToGA.exe,
                };

And both don't work.

Upvotes: 0

Views: 455

Answers (1)

Andrew Hare
Andrew Hare

Reputation: 351456

You should set ProcessStartInfo.WorkingDirectory to the directory that holds acc.txt and GA.exe:

ProcessStartInfo pinfo = new ProcessStartInfo()
{
    Arguments = FolderWithGA.exePath,
    FileName = pathToGA.exe,
    WorkingDirectory = FolderWithGA
};

Upvotes: 3

Related Questions