I have been looking for a simple way to create a shortcut to a file in C#, but I\'ve only found external dlls that do that. It\'s actually quite surprising, there\'s no buil
One way to do this is pointed out by Joepro in their answer here:
You'll need to add a COM reference to Windows Scripting Host. As far as i know, there is no native .net way to do this.
WshShellClass wsh = new WshShellClass(); IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut( Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\shorcut.lnk") as IWshRuntimeLibrary.IWshShortcut; shortcut.Arguments = ""; shortcut.TargetPath = "c:\\app\\myftp.exe"; // not sure about what this is for shortcut.WindowStyle = 1; shortcut.Description = "my shortcut description"; shortcut.WorkingDirectory = "c:\\app"; shortcut.IconLocation = "specify icon location"; shortcut.Save();
For .Net 4.0 and above, replace the first line with the following:
WshShell wsh = new WshShell();
EDIT: This link can help too