HashSet <IWshShortcut> findShortcuts(string dir) { Regex lnkre = new Regex(@"\.lnk$", RegexOptions.IgnoreCase | RegexOptions.Singleline); HashSet <IWshShortcut> ret = new HashSet <IWshShortcut>(); FileSystemObject fs = new FileSystemObjectClass(); Folder folder = fs.GetFolder(dir); foreach (IWshRuntimeLibrary.File file in folder.Files) { if (file == null) { break; } if (!lnkre.IsMatch(file.Name)) { continue; } IWshShortcut shortcut = (IWshShortcut)wsh.CreateShortcut(file.Path); //IWshShortcut shortcut = (IWshShortcut)wsh.CreateShortcut(@"C:\Users\mysto\Desktop\v2rayN - 快捷方式.lnk"); //Console.WriteLine("{0}{1}{2}{3}{4}", shortcut.FullName, shortcut.TargetPath, shortcut.Arguments, shortcut.IconLocation, shortcut.WorkingDirectory); ret.Add(shortcut); } foreach (IWshRuntimeLibrary.Folder item in folder.SubFolders) { if (item == null) { break; } ret.UnionWith(findShortcuts(item.Path)); } return(ret); }
private object SizeGetter(object rowObject) { if (rowObject is not TreeEntry treeEntry) { return(FileSize.Empty); } if (treeEntry.IsDirectory == false) { return(FileSize.FromBytes(((FileInfo)treeEntry.FileSystemInfo).Length)); } if (FileSystemObject == null || treeEntry.FileSystemInfo is not DirectoryInfo dirInfo || !dirInfo.Exists) { return(FileSize.Empty); } try { var folder = FileSystemObject.GetFolder(dirInfo.FullName); var size = new FileSize(Convert.ToInt64(folder.Size) / 1024); return(size); } catch (Exception ex) { Console.WriteLine(ex); return(FileSize.Empty); } }
public void AddMissingInformation(ApplicationUninstallerEntry target) { if (!Directory.Exists(target.InstallLocation) || UninstallToolsGlobalConfig.IsSystemDirectory(target.InstallLocation)) { return; } if (_everythingAvailable) { try { target.EstimatedSize = EvGetSize(target.InstallLocation); return; } catch (Exception ex) { Console.WriteLine(ex); _everythingAvailable = false; } } if (_fileSystemObject != null) { try { var folder = _fileSystemObject.GetFolder(target.InstallLocation); var size = new FileSize(Convert.ToInt64(folder.Size) / 1024); target.EstimatedSize = size; } catch (Exception ex) { Console.WriteLine(ex); } } }
public void AddMissingInformation(ApplicationUninstallerEntry target) { if (FileSystemObject == null || !Directory.Exists(target.InstallLocation)) { return; } try { var folder = FileSystemObject.GetFolder(target.InstallLocation); var size = new FileSize(Convert.ToInt64(folder.Size) / 1024); target.EstimatedSize = size; } catch (Exception ex) { Console.WriteLine(ex); } }