我正在使用Icon.ExtractAssociatedIcon来获取用户在openfiledialog中选择的文件的图标。问题是,如果用户从网络共享中选择图标,则openfiledialog的文件名属性以UNC格式显示,这会导致ExtractAssocaitedIcon抛出ArgumentException异常:
Value of '\\server\share\filename' is not valid for 'filePath'.
Stack Trace:
at System.Drawing.Icon.ExtractAssociatedIcon(String filePath, Int32 index)
我的问题是,给定一个指定为\\server\share\filename
的文件,我该如何获取图标?
注意: .NET 2.0