gpt4 book ai didi

c# - 异常: System. ComponentModel.Win32Exception : Invalid data at System. Diagnostics.Process.Start_shell

转载 作者:太空宇宙 更新时间:2023-11-04 04:23:50 24 4
gpt4 key购买 nike

我正在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";

关于c# - 异常: System. ComponentModel.Win32Exception : Invalid data at System. Diagnostics.Process.Start_shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10932229/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com