我正在研究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
我做错了什么!请任何人帮助我...
提前感谢...
参数之间需要空格。试试这个:
process.StartInfo.Arguments = @"""" + pathToDB + @""" ""$" + contents + @"$"" " + "documentTerms";