2012-10-10 22 views
0

我試圖啓動應用程序「GA.exe」,但啓動時它正在從文件「acc.txt」中獲取數據。 如果我正常啓動它(通過雙擊:-))它可以工作,但如果我使用下面的代碼,它會說「無法找到acc.txt」。C#Process.Start() - 目標應用程序找不到文件

我最初的想法:

Process.Start(pathToGA.exe); 

設想二:

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

而且都不起作用。

回答

3

應設置ProcessStartInfo.WorkingDirectory到存放目錄acc.txtGA.exe

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