从C#运行exe,参数中包含空格
我正为这个挠头呢。我试图使用system.diagnostics从C#运行一个exe,但它没有正确地传递我的参数,因此exe失败 它在单词“here”(见下文)后分割路径,因为其中有空格 有人知道我如何在不重命名目录的情况下解决这个问题吗(这对我来说不是一个选项) 这可以从命令行执行:从C#运行exe,参数中包含空格,c#,C#,我正为这个挠头呢。我试图使用system.diagnostics从C#运行一个exe,但它没有正确地传递我的参数,因此exe失败 它在单词“here”(见下文)后分割路径,因为其中有空格 有人知道我如何在不重命名目录的情况下解决这个问题吗(这对我来说不是一个选项) 这可以从命令行执行: Process myexternalexe = new Process(); myexternalexe.StartInfo.FileName = @"C:\Users\me\Desktop\myexterna
Process myexternalexe = new Process();
myexternalexe.StartInfo.FileName = @"C:\Users\me\Desktop\myexternalexe\myexternalexe.exe";
myexternalexe.StartInfo.Arguments = @"comments \\192.168.1.1\a\here is the problem\c\d\";
myexternalexe.Start();
“C:\Users\me\Desktop\myexternalexe\myexternalexe.exe”注释“\192.168.1.1\a\问题出在这里\C\d\”
这不是来自Visual Studio中的:
Process myexternalexe = new Process();
myexternalexe.StartInfo.FileName = @"C:\Users\me\Desktop\myexternalexe\myexternalexe.exe";
myexternalexe.StartInfo.Arguments = @"comments \\192.168.1.1\a\here is the problem\c\d\";
myexternalexe.Start();
但是你省略了C版本中的引用。应该是:
myexternalexe.StartInfo.Arguments = @"comments ""\\192.168.1.1\a\here is the problem\c\d\""";
你查过了吗
在你的情况下,以下方法应该有效
string folderName = @"\\192.168.1.1\a\here is the problem\c\d\";
myexternalexe.StartInfo.Arguments= @"comments" + " \"" + folderName +"\"";
您是否尝试过:
alexe.StartInfo.Arguments = "comments \"\\\\192.168.1.1\\a\\here is the problem\\c\\d\\\"";
我真的不确定,但尝试用%20替换空格