用户完成我的 GUI 后,我必须触发另一个应用程序。为了触发另一个应用程序,我必须传递一些命令行参数来启动该应用程序。假设我必须通过以下参数:
c:\Program File\application.exe -name text -cmdfile c:\text\open.txt
application.exe 是我想传递给另一个应用程序的参数。
之前,该应用程序在Visual Studio -> Properties -> Debug中将这些参数设置为“ c:\Program File\application.exe” -name text -cmdfile c:\text\open.txt
据我了解,上面字符串中的每个空格都被视为一个参数,除了双引号内的那个,所以“c:\Program File\application.exe”是第一个参数,-name是第二个,text是第三个。但是,如果我使用ProcessStartInfo.Argument属性,如果我设置"c:\Program File\application.exe" -name text -cmdfile c:\text\open.txt,它首先给出一个错误,然后我在字符串末尾添加双引号,另一个应用程序将c:\Program作为第一个参数,将File\application.exe作为第二个参数。
如何避免空格作为参数的分隔符?如何使用ProcessStartInfo.Argument在 Visual Studio -> Properties -> Debug as " c:\Program File\application.exe" -name text -cmdfile c:\text\open.txt 中将整个字符串作为相同格式设置传递财产?
ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.Arguments = "c:\Program File\application.exe" -name text -cmdfile c:\text\open.txt
(错误)
如果
startInfo.Arguments = "c:\Program File\application.exe -name text -cmdfile c:\text\open.txt"
它以c:\Program作为第一个参数,File\application.exe作为第二个参数。
我怎么能弄清楚这个?有这方面的经验吗?先感谢您。