Folder Icon Change

前端 未结 3 791
既然无缘
既然无缘 2020-12-18 08:34

I am changing the folder icons with c# function. Its working fine but the problem is its working for first time. I mean I am not able to change the icon for the folder for w

相关标签:
3条回答
  • 2020-12-18 09:02

    Just change

    UInt32 FCS_WRITE = FCS_READ | FCS_FORCEWRITE;
    

    to

    UInt32 FCS_WRITE = FCS_FORCEWRITE;
    

    When you run next time the FCS_WRITE = FCS_READ, so it wont write agian.

    0 讨论(0)
  • 2020-12-18 09:24

    I've faced with similar issue. Just remove the desktop.ini file before calling the function for the second time. The same scenario is used if you would like to clear folder icon:

    1. Remove desktop.ini.
    2. Omit the following lines:

    ....

    FolderSettings.pszIconFile = @"{icon path}";
    FolderSettings.iIconIndex = 0;
    

    ....

    0 讨论(0)
  • 2020-12-18 09:24

    Just for completion, the code in question looks OK, but the 3rd param in the SHGetSetFolderCustomSettings call must be FCS_FORCEWRITE in order to change the settings if already present. (FCS_WRITE will set it ONLY if values NOT already present)

    See docs about that parameter: http://msdn.microsoft.com/en-us/library/windows/desktop/bb762199(v=vs.85).aspx

    0 讨论(0)
提交回复
热议问题