这是我用C#创建快捷方式的代码。它仅适用于非UNC路径,f。恩。使用“C:\ Users \ MsX \ Documents \ ABC”,但“\\ abc \ klk \ somepath”不起作用。
public static void CreateShortcut(string SourceFile, string ShortcutFile, string Description, string Arguments, string HotKey, string WorkingDirectory) {
// Check necessary parameters first:
if (String.IsNullOrEmpty(SourceFile))
throw new ArgumentNullException("SourceFile");
if (String.IsNullOrEmpty(ShortcutFile))
throw new ArgumentNullException("ShortcutFile");
// Create WshShellClass instance:
var wshShell = new WshShellClass();
// Create shortcut object:
IWshRuntimeLibrary.IWshShortcut shorcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(ShortcutFile);
// Assign shortcut properties:
shorcut.TargetPath = SourceFile;
shorcut.Description = Description;
if (!String.IsNullOrEmpty(Arguments))
shorcut.Arguments = Arguments;
if (!String.IsNullOrEmpty(HotKey))
shorcut.Hotkey = HotKey;
if (!String.IsNullOrEmpty(WorkingDirectory))
shorcut.WorkingDirectory = WorkingDirectory;
// Save the shortcut:
shorcut.Save();
}
如何创建显示网络UNC文件夹的快捷方式?
由于