Reputation: 1319
I am creating Internet shortcut using the following code. But the icon of the shortcut which I am setting is not getting displayed in the case of desktop. But if I am manually renaming the shortcut to some other name its working fine(icon is getting loaded as shortcut image).
private String CreateDeskTopShortcut(String ApplicationStartupUrl, String IconFilePath)
{
string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
String UrlPath = deskDir + "\\" + "Test" + ".url";
using (StreamWriter writer = new StreamWriter(UrlPath))
{
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=" + ApplicationStartupUrl);
writer.WriteLine("IconFile=" + IconFilePath);
writer.WriteLine("IconIndex=0");
writer.Flush();
}
return UrlPath;
}
calling the same as
CreateDeskTopShortcut("https://ipAddress/website/Login.aspx","E:\Setup_Local\Server.ico");
Upvotes: 0
Views: 628
Reputation: 1596
It looks like Windows caches the icon path, and this persists even if you delete the file. I have no idea where this cache is stored, or if it persists beyond a reboot. My reproduction steps were as follows:
So the icon used seems to be mapped to the name of the shortcut.
Upvotes: 1