public static Icon GetFileIcon(string path, IconSizeEnum iconsize) { if (string.IsNullOrEmpty(path)) { return((Icon)null); } try { if (!File.Exists(path) && !Directory.Exists(path)) { if (path.Equals("\\")) { goto nullIcon; } } //Mono dont support PNG icon (crash if try to use ICON.ToBitmap()) if ((bool)Globals.RuntimeSettings["Mono"] == true) { return(GetIcon(path)); } if ((int)Globals.RuntimeSettings["defaultFileIconType"] != 16384) { return(GetIcon(path)); } DelegateGetSystemIcon delegateGetSystemIcon = new DelegateGetSystemIcon(GetSystemIcon); IAsyncResult result = delegateGetSystemIcon.BeginInvoke(path, iconsize, (AsyncCallback)null, (object)null); return(delegateGetSystemIcon.EndInvoke(result)); } catch { } nullIcon: return((Icon)null); }
public static Icon GetFileIcon(string path, IconSizeEnum iconsize) { if (string.IsNullOrEmpty(path)) return (Icon)null; try { if (!File.Exists(path) && !Directory.Exists(path)) { if (path.Equals("\\")) goto nullIcon; } //Mono dont support PNG icon (crash if try to use ICON.ToBitmap()) if ((bool)Globals.RuntimeSettings["Mono"] == true) { return GetIcon(path); } if ((int)Globals.RuntimeSettings["defaultFileIconType"] != 16384) { return GetIcon(path); } DelegateGetSystemIcon delegateGetSystemIcon = new DelegateGetSystemIcon(GetSystemIcon); IAsyncResult result = delegateGetSystemIcon.BeginInvoke(path, iconsize, (AsyncCallback)null, (object)null); return delegateGetSystemIcon.EndInvoke(result); } catch { } nullIcon: return (Icon)null; }