C#获取系统相关的文件Icon
public Icon LoadIconFromExtension(string extension) { string path = string.Format("dummy{0}", extension); using (File.Create(path)) { } Icon icon = Icon.ExtractAssociatedIcon(path); File.Delete(path); return icon; }
关键是创建了临时文件
public Icon LoadIconFromExtension(string extension) { string path = string.Format("dummy{0}", extension); using (File.Create(path)) { } Icon icon = Icon.ExtractAssociatedIcon(path); File.Delete(path); return icon; }
关键是创建了临时文件