public static bool CanDecode(IDataObject data) { if (!FileGroupDescriptor.CanDecode(data)) { return(false); } foreach (FileGroupDescriptor.File i in FileGroupDescriptor.Decode(data)) { if (i.Name.EndsWith(".url", StringComparison.OrdinalIgnoreCase)) { return(true); } } return(false); }
public static IEnumerable <InternetShortcut> Decode(IDataObject data) { WshShell shell = new WshShell(); foreach (FileGroupDescriptor.File i in FileGroupDescriptor.Decode(data)) { if (i.Name.EndsWith(".url", StringComparison.OrdinalIgnoreCase)) { string path = i.Write(System.Environment.GetEnvironmentVariable("TEMP")); IWshURLShortcut wshSc = (IWshURLShortcut)shell.CreateShortcut(path); System.IO.File.Delete(path); InternetShortcut sc = new InternetShortcut(); sc.Name = i.Name; sc.Url = wshSc.TargetPath; yield return(sc); } } }