示例#1
0
        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);
        }
        static FastSizeGenerator()
        {
            try
            {
                _fileSystemObject = new FileSystemObjectClass();
            }
            catch (Exception ex)
            {
                Console.WriteLine(@"FastSizeGenerator: Scripting.FileSystemObjectClass is not available - " + ex.Message);
            }

            try
            {
                if (EvGetSize(UninstallToolsGlobalConfig.AssemblyLocation).GetRawSize(false) == 0)
                {
                    throw new SystemException("Test failed to get valid BCU directory size");
                }

                _everythingAvailable = true;
            }
            catch (SystemException ex)
            {
                _everythingAvailable = false;
                Console.WriteLine(@"FastSizeGenerator: Everything search engine is not available - " + ex.Message);
            }
        }
示例#3
0
 static TargetList()
 {
     try
     {
         FileSystemObject = new FileSystemObjectClass();
     }
     catch (Exception ex)
     {
         Console.WriteLine(@"WARNING: Scripting.FileSystemObjectClass is not available - " + ex.Message);
     }
 }