File Type Icon not updating in Visual Studio

5.7k Views Asked by At

So long story short, I followed the instructions here to have my program open when a specific file type is double clicked. http://www.dreamincode.net/forums/topic/58005-file-associations-in-visual-studio/

I included an Icon to be associated with the specified file type. The problem that arises is that when I go back to update/change that icon image and attempt to reinstall a newer version of the program, the old icon is used and not the one I changed it to be in visual studio...

3

There are 3 best solutions below

2
On

The icon is probably cached in the shell icon cache. Delete %USERPROFILE%\AppData\Local\IconCache.db (and kill explorer or log off) on NT6 or use TweakUI on older systems.

1
On

Try using SHChangeNotify

[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern void SHChangeNotify(int wEventId, int uFlags, IntPtr dwItem1, IntPtr dwItem2);

SHChangeNotify(0x08000000, 0x0000, (IntPtr)null, (IntPtr)null);//SHCNE_ASSOCCHANGED SHCNF_IDLIST
0
On

There are two steps to make the icon to update: 1. overwrite the old .ico file in the project folder (or wherever it's kept) with the new file - this will update the icon in the Application Properties. 2. Edit the Mainform, go to the icon property and re-select the icon file - this update the icon shown on the window and the task bar.