2

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...

Kevin Nguyen
  • 21
  • 1
  • 4
  • The OS keeps a cache of these icons. This may be the source of your problem. If so, clearing the cache should fix it. Try searching for "windows icon cache rebuild". – phoog May 12 '12 at 00:22

3 Answers3

3

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.

Anders
  • 97,548
  • 12
  • 110
  • 164
  • This is indeed the problem. Thanks everyone for the good and quick responses, being a total nooby programmer, is there any way I can do this programmatically in the solution/deployment? – Kevin Nguyen May 12 '12 at 02:27
  • This problem is more common on a development machine, I would NOT recommend that you try to delete the cache on the end-users machine. Call SHChangeNotify if VS is not doing it for you, that is the documented way and should be enough in normal scenarios... – Anders May 12 '12 at 14:07
1

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
Musa
  • 96,336
  • 17
  • 118
  • 137
  • So after attempting to call SHChangeNotify, it does not seem to be refreshing. What I found interesting though is the open file dialog in my program (using the c# library) shows the updated icon but If I were to go through windows explorer, the file icons remain the same...(this occurred prior to using SHChangeNotify) – Kevin Nguyen May 15 '12 at 16:13
0

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.

user2867342
  • 165
  • 1
  • 5