C#如何将目录空白空间用于process.arguements?

Jav*_*oob 7 c# directory arguments process

创建的程序使用第三方工具生成日志文件.

但是,为该工具提供的参数需要目录位置中的各种文件作为生成日志的一部分.因此,主要参数@"-r C:\test\ftk\ntuser.dat -d C:\System Volume Information\" + restoreFolder.Name + " -p runmru";将用于生成日志.

有人可以建议如何使系统处理"C:\ System Volume Information"的参数并放置空格?谢谢!

代码:

            Process process = new Process();
            process.StartInfo.FileName = @"C:\test\ftk\ripxp\ripxp.exe";
            process.StartInfo.Arguments = @"-r C:\test\ftk\ntuser.dat -d C:\System Volume Information\" + restoreFolder.Name + " -p runmru";
            process.StartInfo.CreateNoWindow = false;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardInput = true;
            process.StartInfo.RedirectStandardError = true;
            process.Start();
Run Code Online (Sandbox Code Playgroud)

Ode*_*ded 10

你需要"通过附加一个\to(\") - 对于普通字符串,或者将它们加倍("")用于逐字字符串文字(以那些开头的那些@)来逃避:

process.StartInfo.Arguments = @"-r C:\test\ftk\ntuser.dat -d ""C:\System Volume Information\" + restoreFolder.Name + @""" -p runmru";
Run Code Online (Sandbox Code Playgroud)