I'm writing a Windows service application in C# with FileSystemWatcher
.
How can I add status icons to files and folders in Windows Explorer similar to how Dropbox or SVN do it?
Open My Computer or File Explorer. Click View in the menu at the top of the window. If you do not see the View menu, press Alt to make it visible. Select Extra large icons, Large icons, Medium Icons, Small icons, List, Details, Tiles, or Content to change the view you want to see.
Right-click the shortcut you created, click Properties, and then click Change Icon. Click the picture of the icon you would like the shortcut to use, click OK, and then click OK.
You can view and organize files and folders using a built-in application known as File Explorer (called Windows Explorer in Windows 7 and earlier versions). To open File Explorer, click the File Explorer icon on the taskbar, or double-click any folder on your desktop. A new File Explorer window will appear.
For anyone still interessted in this question:
Here is a codeproject link which describes the process in great detail.
It uses the SharpShell library, which can also be found on nuget.
Code, from the codeproject, looks something like that:
[ComVisible(true)]
public class ReadOnlyFileIconOverlayHandler : SharpIconOverlayHandler
{
protected override int GetPriority()
{
// The read only icon overlay is very low priority.
return 90;
}
protected override bool CanShowOverlay(string path, FILE_ATTRIBUTE attributes)
{
try
{
// Get the file attributes.
var fileAttributes = new FileInfo(path);
// Return true if the file is read only, meaning we'll show the overlay.
return fileAttributes.IsReadOnly;
}
catch (Exception) { return false; }
}
protected override System.Drawing.Icon GetOverlayIcon()
{
// Return the read only icon.
return Properties.Resources.ReadOnly;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With