当我在cmd中手动运行命令时,我有一个小问题,使用total- command打开windows系统文件夹是可以的,但当它以ProcessStartInfo身份运行时就不行了。此问题发生在Windows XP上,Windows 7参数(路径)略有不同,但可以正常工作。
ProcessStartInfo startInfo = new ProcessStartInfo(); //New Proccess
startInfo.Arguments = "/L=" + GetArgument(); //Return C:\WINDOWS\system32\config\systemprofile\Local Settings\Application ata\MyApp\update\download [it´s OK]
startInfo.WorkingDirectory = Path.GetDirectoryName(GetTcmdPath());
startInfo.FileName = GetTcmdPath(); //returns C:\Program Files\totalcmd\TOTALCMD.EXE [it´s OK]
Process.Start(startInfo); //Start proccess TC已启动,但路径为: C:\WINDOWS\system32\config\systemprofile,不知道为什么有人可以帮助我?
编辑:当我在没有"的命令C:\Program Files\totalcmd>TOTALCMD.EXE /L=C:\WINDOWS\system32\config\systemprofile\Local Settings\Application Data\MyApp\update\download中运行时
相反,
C:\Program Files\totalcmd>TOTALCMD.EXE /L="C:\WINDOWS\system32\config\systemprofile\Local Settings\Application Data\MyApp\update\download"
它不工作,但不知道如何在程序中添加"?
发布于 2013-10-25 18:33:21
我在我的问题中找到了答案,所以如果您需要在字符串变量中添加双引号,请使用以下内容:
startInfo.Arguments = string.Format("/L=\"{0}\"", GetArgument());
https://stackoverflow.com/questions/19564074
复制相似问题