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