dwmkerr / sharpshell

SharpShell makes it easy to create Windows Shell Extensions using the .NET Framework.
MIT License
1.5k stars 260 forks source link

How change Icon Overlay by file extencion #366

Open cassio-vo opened 2 years ago

cassio-vo commented 2 years ago

if is txt file i want show a green icon, but if isn't a txt file i want show a blue icon.

JereckNET commented 5 months ago

You would need two handlers.

One for the green icon :

protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) {
   FileInfo fiPath = new FileInfo(path);

   return (fiPath.Extension.Equals(".txt"));
}
protected override Icon GetOverlayIcon() {
   return Properties.Resources.GreenIcon;
}

And another one for the blue icon :

protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes) {
   FileInfo fiPath = new FileInfo(path);

   return !(fiPath.Extension.Equals(".txt"));
}
protected override Icon GetOverlayIcon() {
   return Properties.Resources.BlueIcon;
}