When use Process.startInfo.Arguments, I ha开发者_如何学运维ve filename as one of the argument,
StartInfo.Arguments = filename
I am wondering how to make sure it is correct in the case that filename is "test test".
I would simply always quote it; since "test" is valid too.
I don't know if there is inbuilt file escaping anywhere, but
procStart.Arguments = "blah blip -in \"" + filePath + "\" more args";
should do...
If you wanted you could get fancy with checking the input string (filePath
above), but it probably isn't worth checking the edge-cases. For the same reason that if I'm writing TSQL over an unknown table, I'd always add explicit [
/ ]
(without bothering to check if it needs it).
精彩评论