开发者

.NET: How to pass command-line parameters with a temp file name

This is .NET 2.0 WinForms. I have some code like so

string str = Path.GetTempFileName();
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.Arguments = str
psi.FileName = <some executable >
p.StartInfo = psi;
p.Start();

Now on the "started" process I get the temp file name by saying args[0]. On Win XP this is causing an issue as the temp file is 开发者_如何学Goin C:\Documents and Settings\.... The space is causing an issue, thus args[0] is C:\Documents.

How can I fix this? Do I just have to place str in quotes? Or can I get the whitespace to be ignored somehow?


Yes, use quotes.


You can either wrap the path in double quotes or you can convert the path into its short (8.3) representation using the native GetShortPathName function.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜