开发者

Using strings with StartInfo.FileName in C#

I am getting some odd results when trying to run a process from a string:

                    Process p = new Process();
                    p.StartInfo.WorkingDirectory = "dump";
                    p.StartInfo.FileName = s;
                    p.Start();

s = run.ex开发者_JS百科e "mp4:production/CATCHUP/"

I am getting odd results such as:

"test.exe \"mp4:production/CATCHUP/\""

Obviously when this command executes, it throws an exception, how can I get rid of all of the backspaces?


May be I understand your problem. At least looking on your code, it seems to me that you pass like a p.StartInfo.FileName=s, where s="test.exe **\"mp4:production/CATCHUP/\"**" where part in bold is an argument for executable, which is wrong

Try to do something like this:

  Process p = new Process();
  p.StartInfo.WorkingDirectory = "dump";
  p.StartInfo.FileName = "test.exe"; // only executable name run or test???
  p.StartInfo.Arguments = "mp4:production/CATCHUP/"; //only arguments
  p.Start();

Regards.

EDIT

Good notice that in code presented run.exe became accidentially test.exe +1 for @Hans

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜