localsynchronizationsetup_p.../LocalSynchronizationSetup/Shortcut.cs

22 lines
603 B
C#

using IWshRuntimeLibrary;
namespace LocalSynchronizationSetup
{
public static class Shortcut
{
public static void Create(string text, string sourceFile, string destPath)
{
if (destPath.Substring(destPath.Length - 1, 1) != "\\")
{
destPath += "\\";
}
string shortcutPath = destPath + text + ".lnk";
WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(shortcutPath);
link.TargetPath = sourceFile;
link.Save();
}
}
}