I want to create an internet shortcut (url file) with a custom icon on the desktop. To create the shortcut, I currently use:
private void CreateShortcut(string name, string url)
{
string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
using (StreamWriter writer = new StreamWriter(deskDir + "\\" + name + ".url"))
{
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=" + url);
writer.Flush();
}
}
But this code does not set a custom icon. How would I set the icon?
Set IconIndex
and IconFile
parameters:
[InternetShortcut]
URL=<url>
IconIndex=0
IconFile=<path to custom icon icon file>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With