【发布时间】:2016-03-27 05:16:08
【问题描述】:
我一直在使用下面的代码来动态创建快捷方式。但是当文件夹名称包含 unicode 字符(如泰语、希腊语)时,targetPath 会引发 Argument 异常。
IWshRuntimeLibrary.WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
shortcut.Description = "My shortcut description"; // The description of the shortcut
shortcut.WorkingDirectory = currentPath;
shortcut.TargetPath = targetFileLocation; // The path of the file that will launch when the shortcut is run
shortcut.Save();
【问题讨论】:
-
您可能需要为无法处理的 unicode 字符创建替换字符串(如 u1234)的逻辑。