2013-03-05 67 views
0

我需要執行c:\中的進程。當我使用Process.Processstartinfo時,它不會從c:\執行,因此無法找到它的依賴關係。它運行在我的應用程序目錄中。我如何在c:\目錄中運行它?在特定目錄中執行進程

+1

我認爲你不需要這個問題的'g ++'標記。請分享你已經嘗試過的東西。你可以/應該閱讀[常問問題]和[問] – 2013-03-05 07:39:21

回答

2

您是否設置了WorkingDirectory

process.StartInfo.WorkingDirectory = @"MyWorkingDirectoryPath"; 

例如爲:

var psi = new ProcessStartInfo(); 
psi.WorkingDirectory = @"MyWorkingDirectoryPath"; 

// set additional properties 

Process proc = Process.Start(psi); 

UseShellExecute屬性爲false,獲取或設置工作 目錄要啓動的過程。當UseShellExecute爲 爲真時,獲取或設置包含進程的目錄爲 已啓動。

+0

工作目錄是什麼意思,它的過程開始和工作的目錄 – 2013-03-05 07:47:52

+0

這不工作,我嘗試我有應用程序.exe我測試它打開input.txt並在input.txt中寫入文本輸出.txt並且它不會在c:\(工作目錄)中創建output.txt – 2013-03-05 07:57:46

0

ProcessStartInfo.WorkingDirectory設置爲您要啓動的進程的工作目錄,即您的情況"C:\"