内容简介:代码日志版权声明:翻译自:http://stackoverflow.com/questions/17321289/use-process-start-with-parameters-and-spaces-in-path
我看过类似的例子,但找不到像我的问题那样的东西.
我需要从C#运行这样的命令:
C:\FOLDER\folder with spaces\OTHER_FOLDER\executable.exe p1=hardCodedv1 p2=v2
我在运行时设置v2,所以我需要在调用Process.Start之前修改C#中的字符串.有谁知道如何处理这个,因为我的参数之间有空格?
类来分隔参数FileName,WorkingDirectory和参数,而不用担心空格
string fullPath = @"C:\FOLDER\folder with spaces\OTHER_FOLDER\executable.exe" ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = Path.GetFileName(fullPath); psi.WorkingDirectory = Path.GetDirectoryName(fullPath); psi.Arguments = "p1=hardCodedv1 p2=" + MakeParameter(); Process.Start(psi);
其中MakeParameter是一个返回要用于p2参数的字符串的函数
代码日志版权声明:
翻译自:http://stackoverflow.com/questions/17321289/use-process-start-with-parameters-and-spaces-in-path
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Java Language Specification, Java SE 7 Edition
James Gosling、Bill Joy、Guy L. Steele Jr.、Gilad Bracha、Alex Buckley / Addison-Wesley Professional / 2013-2-24 / USD 59.99
Written by the inventors of the technology, The Java(r) Language Specification, Java SE 7 Edition, is the definitive technical reference for the Java programming language. The book provides complete, ......一起来看看 《The Java Language Specification, Java SE 7 Edition》 这本书的介绍吧!