我想通過C#代碼運行perl腳本。 perl腳本將一個文本文件作爲輸入,並創建兩個新文件作爲輸出(在兩者之間進行一些文本處理)。當我使用下面的代碼通過C#運行perl腳本時,它似乎開始執行,但沒有創建文件。有什麼問題?語法錯誤?運行Perl通過C#代碼
ProcessStartInfo perlStartInfo = new ProcessStartInfo(@"c:\Perl\bin\perl.exe");
perlStartInfo.Arguments = "c:\\Perl\\DOC-MAT.pl " + "c:\\Perl\\comb1.txt" + "c:\\Perl\\comb1.mat";
perlStartInfo.UseShellExecute = false;
perlStartInfo.RedirectStandardOutput = true;
perlStartInfo.RedirectStandardError = true;
perlStartInfo.CreateNoWindow = false;
Process perl = new Process();
perl.StartInfo = perlStartInfo;
perl.Start();
perl.WaitForExit();
string output = perl.StandardOutput.ReadToEnd();
這裏,comb1.txt是我的輸入文件,並comb1.mat和comb1.clabel應當由Perl代碼越來越創建的文件。
1)該程序是否具有'C:\ Perl'的寫權限? 2)是否有可能將文件寫入標準輸出並因此寫入「字符串輸出」? – 2012-02-13 09:49:38