I am using Icon.ExtractAssociatedIcon to get the icon of a file , that a user selects, in an openfiledialog.
THe problem is if the user selects an icon from a network share then the filename property of the openfiledialog is in UNC format and this causes an ArgumentException
in ExtractAssocaitedIcon
:
Value of '\serversharefilename' is not valid for 'filePath'.
Stack Trace:
at System.Drawing.Icon.ExtractAssociatedIcon(String filePath, Int32 index)
So my question is given a file specified as \serversharefilename
, how do I get the icon?
Note: .NET 2.0
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…