Word命令行参数空间问题

本文关键字:问题 参数空间 命令行 Word | 更新日期: 2023-09-27 18:07:36

我想通过使用Environment.GetCommandLineArgs()将参数传递给winword,以便在我的vsto插件中读取它。

如果参数值包含空格,则无法转义字符串。

正在运行:

winword.exe /myVar1:C:'folder'whatever1.doc /myVar2:C:'folder'somethingelese.txt C:'example.doc

这是不工作:

winword.exe /myVar1:"C:'folder with space'whatever1.doc" /myVar2:"C:'folder with space 2'somethingelese.txt" C:'example.doc

Word命令行参数空间问题

试试下面的命令:

winword.exe "/myVar1:C:'folder with space'whatever1.doc" "/myVar2:C:'folder with space 2'somethingelese.txt" C:'example.doc

如果它仍然不能工作,发送给我们GetCommandLineArgs返回的数组的内容