C# How to set folder icon?

点点圈 提交于 2019-12-10 11:23:31

问题


I use FilePathDialog.SelectedPath get folder's path I also know icon's path but i don't know how to set that folder's icon


回答1:


this website has a very similar example




回答2:


You have to write the desktop.ini file.

[.ShellClassInfo]
IconResource=Icon.ico,0
IconFile=Icon.ico
IconIndex=0
[ViewState]
Mode=
Vid=
FolderType=Pictures

C# code

string dir = "Folder Path";   
string[] lines = { "[.ShellClassInfo]", "IconResource=Icon.ico,0", "[ViewState]", "Mode=", "Vid=", "FolderType=Pictures" };
File.WriteAllLines(dir + @"\desktop.ini", lines);

IconResource: {Icon Path},0
FolderTypes: Generic, Documents, Pictures, Music, Videos

If you need more information, check this GitHub project: https://github.com/FIC-Folder-Icon-Changer



来源:https://stackoverflow.com/questions/6531898/c-sharp-how-to-set-folder-icon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!