Skip to main content
 首页 » 编程设计

c#之在 C# 中打开路径中有空格的 Word 文档

2024年02月23日20xiaohuochai

我有这条路;

path = Cash Report\\30-03-2012 01-11-07 Cash Flow Report.Docx 

当我使用下面的代码打开文件时,它会尝试打开每个单词。所以它会尝试打开 cash.doc,然后是 Report.doc 等等;

//Open the newly created file 
        ProcessStartInfo startInfo = new ProcessStartInfo(); 
        startInfo.FileName = "WINWORD.EXE"; 
        startInfo.Arguments = path; 
        Process.Start(startInfo); 

有没有办法忽略空格?!

请您参考如下方法:

尝试

path="\"Cash Report\\30-03-2012 01-11-07 Cash Flow Report.Docx\""