To programatically change the icon of a folder, I found that I need to set the folder's attribute to be a system folder.
Guide I worked with: http://www.codeproject.com/Articles/9331/Create-Icons-for-Folders-in-Windows-Explorer-Using
And the relevant code:
File.SetAttributes(folderPath, File.GetAttributes(folderPath) | FileAttributes.System);
Looking at the documentation, this function should have thrown an exception for a folder path as parameter:
https://msdn.microsoft.com/en-us/library/system.io.file.setattributes%28v=vs.110%29.aspx
Is this really the correct API?
In addition, what are the consequences of setting it as a system folder?