Ejemplo n.º 1
0
        static async Task UnSevenzip(string path)
        {
            Logger.Log("[Installer] Extracting " + path);
            await Task.Delay(20);

            SevenZipNET.SevenZipExtractor.Path7za = path7za;
            SevenZipNET.SevenZipExtractor extractor = new SevenZipNET.SevenZipExtractor(path);
            extractor.ExtractAll(IOUtils.GetAppDataDir(), true, true);
            File.Delete(path);
            await Task.Delay(10);
        }
Ejemplo n.º 2
0
 static async Task ExtractAsync()
 {
     await Task.Run(async() =>
     {
         SevenZipNET.SevenZipExtractor.Path7za   = Path.Combine(Installer.path, "7za.exe");
         SevenZipNET.SevenZipExtractor extractor = new SevenZipNET.SevenZipExtractor(downloadPath);
         await Task.Delay(1);
         extractor.ExtractAll(Installer.path, true, true);
         File.Delete(downloadPath);
         isExtracting = false;
     });
 }
Ejemplo n.º 3
0
        private static void Initialize()
        {
            if (_pluginDirName != null && _pluginDirName.Exists)
            {
                return;
            }

            var assLocation = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            _directoryName = new DirectoryInfo(Path.Combine(assLocation.FullName, "SB3UGS"));
            _pluginDirName = new DirectoryInfo(Path.Combine(_directoryName.FullName, "plugins"));

            if (!_directoryName.Exists || !_pluginDirName.Exists)
            {
                try { _directoryName.Delete(true); }
                catch (Exception ex) { Console.WriteLine(ex); }

                Console.WriteLine("Could not find a valid SB3UGS install, attempting to install a fresh one");

                var target = assLocation.GetFiles("SB3UGS*.7z").Where(x => !x.Name.Contains("_src")).OrderByDescending(x => x.Length).FirstOrDefault();
                if (target != null)
                {
                    Console.WriteLine("Found " + target.Name + " - attempting to extract");

                    var extr = new SevenZipNET.SevenZipExtractor(target.FullName);

                    if (!extr.TestArchive())
                    {
                        throw new IOException("Archive " + target.Name + " is not valid or is corrupted");
                    }

                    extr.ExtractAll(_directoryName.FullName, true, true);

                    _directoryName.Refresh();
                    _pluginDirName.Refresh();
                    if (!_directoryName.Exists || !_pluginDirName.Exists)
                    {
                        throw new IOException("Archive " + target.Name + " did not contain the correct files or it failed to extract");
                    }
                }
            }

            _sb3uDlls = _pluginDirName.GetFiles("*.dll").Concat(_directoryName.GetFiles("*.dll")).ToDictionary(x => Path.GetFileNameWithoutExtension(x.Name), x => x);

            AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;

            LoadPlugin(Path.Combine(_pluginDirName.FullName, "SB3UtilityPlugins.dll"));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 解压文件
        /// </summary>
        public static bool UnZipFile(string filePath)
        {
            var flag = true;

            try
            {
                if (File.Exists(filePath))
                {
                    var SevenZip = new SevenZipNET.SevenZipExtractor(filePath);
                    SevenZip.ExtractAll(AppContext.BaseDirectory);
                    File.Delete(filePath);//解压完成移除压缩包
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(flag);
        }