Example #1
0
    /// <summary>
    /// Removes the folder's icon
    /// </summary>
    /// <param name="wszPath">??</param>
    /// <returns></returns>
    public HResult ClearFolderIcon(String wszPath) {
      var fcs = new Shell32.LPSHFOLDERCUSTOMSETTINGS() { dwMask = Shell32.FCSM_ICONFILE };
      fcs.dwSize = (UInt32)Marshal.SizeOf(fcs);

      HResult hr = Shell32.SHGetSetFolderCustomSettings(ref fcs, wszPath, Shell32.FCS_FORCEWRITE);
      if (hr == HResult.S_OK) {
        // Update the icon cache
        this.UpdateIconCacheForFolder(wszPath.Replace(@"\\", @"\"));
      }

      this.RefreshItem(this._SelectedIndexes[0]);
      return hr;
    }
Example #2
0
 /// <summary>
 /// Sets the folder's icon
 /// </summary>
 /// <param name="wszPath">??</param>
 /// <param name="wszExpandedIconPath">??</param>
 /// <param name="iIcon">??</param>
 public void SetFolderIcon(String wszPath, String wszExpandedIconPath, Int32 iIcon) {
   var fcs = new Shell32.LPSHFOLDERCUSTOMSETTINGS() { iIconIndex = iIcon, cchIconFile = 0, dwMask = Shell32.FCSM_ICONFILE };
   fcs.dwSize = (UInt32)Marshal.SizeOf(fcs);
   fcs.pszIconFile = wszExpandedIconPath.Replace(@"\\", @"\");
   // Set the folder icon
   HResult hr = Shell32.SHGetSetFolderCustomSettings(ref fcs, wszPath.Replace(@"\\", @"\"), Shell32.FCS_FORCEWRITE);
   if (hr == HResult.S_OK) this.UpdateIconCacheForFolder(wszPath); // Update the icon cache			
   this.RefreshItem(this._SelectedIndexes[0], true);
 }