0

我正在研究 linux 环境并使用 Mono 进行开发。我有一个 C# 项目,我想在其中启动另一个应用程序/可执行文件。代码片段如下:

string pathToDB = @"""/root/somefolder/anotherfolder/""";
                        Process process = new Process();
                        process.StartInfo.FileName = @"/root/somefolder/filename";
                        process.StartInfo.Arguments = @"""" + pathToDB + @"""" + "$" + contents + "$" + "documentTerms";
                        process.Start();    

我传递了三(3)个参数。第一个是文件夹路径,第二个是我用字符串内容表示的一些文本数据,第三个是一些硬编码文本。当我运行这个程序时,它给了我以下异常/错误:

CreateProcess: Unfinished quote.

Exception: System.ComponentModel.Win32Exception: Invalid data
at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Process.Start () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
  at XapianTest.SimpleIndex.ProcessFiles (System.String path) [0x000dc] in /root/Projects/XapianTest/XapianTest/SimpleIndex.cs:84 
  at XapianTest.SimpleIndex.ProcessFiles (System.String path) [0x0013d] in /root/Projects/XapianTest/XapianTest/SimpleIndex.cs:105 
  at XapianTest.SimpleIndex.ProcessFiles (System.String path) [0x0013d] in /root/Projects/XapianTest/XapianTest/SimpleIndex.cs:105 
  at XapianTest.SimpleIndex.Main (System.String[] argv) [0x00023] in /root/Projects/XapianTest/XapianTest/SimpleIndex.cs:51    

我究竟做错了什么!请任何人帮助我...

提前致谢...

4

1 回答 1

0

你需要在参数之间有空格。尝试这个:

process.StartInfo.Arguments = @"""" + pathToDB + @""" ""$" + contents + @"$"" " + "documentTerms";
于 2012-06-07T15:05:40.433 回答