当前位置: 首页>>代码示例>>C#>>正文


C# ZipArchive.ExtractToDirectory方法代码示例

本文整理汇总了C#中System.IO.Compression.ZipArchive.ExtractToDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# ZipArchive.ExtractToDirectory方法的具体用法?C# ZipArchive.ExtractToDirectory怎么用?C# ZipArchive.ExtractToDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Compression.ZipArchive的用法示例。


在下文中一共展示了ZipArchive.ExtractToDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InstallModule

        private static bool InstallModule() {
            try {
                var ini = new IniFile(Path.Combine(FileUtils.GetDocumentsCfgDirectory(), "launcher.ini"));
                var theme = ini["WINDOW"].GetNonEmpty("theme");
                var directory = Path.Combine(AcRootDirectory.Instance.RequireValue, @"launcher", @"themes", theme ?? @"default", @"modules", ModuleId);

                var installed = false;
                if (!Directory.Exists(directory)) {
                    Directory.CreateDirectory(directory);

                    using (var stream = new MemoryStream(BinaryResources.ModuleCmHelper))
                    using (var archive = new ZipArchive(stream)) {
                        archive.ExtractToDirectory(directory);
                    }

                    installed = true;
                }

                var active = ini["MODULES"].GetStrings("ACTIVE");
                if (!active.Contains(ModuleId)) {
                    ini["MODULES"].Set("ACTIVE", active.Append(@"CmHelper").Distinct());
                    ini.Save();
                    installed = true;
                }

                return installed;
            } catch (Exception e) {
                throw new InformativeException("Can’t install UI module", e);
            }
        }
开发者ID:gro-ove,项目名称:actools,代码行数:30,代码来源:ModuleStarter.cs

示例2: Update

 /// <summary>
 /// Downloads the specified web driver version.
 /// </summary>
 /// <param name="version">The version to download.</param>
 protected override void Update(string version)
 {
     using (var client = new WebClient())
     using (var stream = client.OpenRead("http://chromedriver.storage.googleapis.com/" + version + "/chromedriver_win32.zip"))
     using (var archive = new ZipArchive(stream))
         archive.ExtractToDirectory(Path.Combine(ParentPath, version));
 }
开发者ID:stuartleeks,项目名称:BrowserBoss,代码行数:11,代码来源:ChromeWebDriverSetup.cs

示例3: ButtonRestore_Click

		private async void ButtonRestore_Click(object sender, RoutedEventArgs e)
		{
			var selected = ListBoxBackups.SelectedItem as BackupFile;
			if(selected != null)
			{
				var result =
					await
					Helper.MainWindow.ShowMessageAsync("Restore backup " + selected.DisplayName,
					                                   "This can not be undone! Make sure you have a current backup (if necessary). To create one, CANCEL and click \"CREATE NEW\".",
					                                   MessageDialogStyle.AffirmativeAndNegative);
				if(result == MessageDialogResult.Affirmative)
				{
					var archive = new ZipArchive(selected.FileInfo.OpenRead(), ZipArchiveMode.Read);
					archive.ExtractToDirectory(Config.Instance.DataDir, true);
					Config.Load();
					Config.Save();
					DeckList.Load();
					DeckList.Save();
					DeckStatsList.Load();
					DeckStatsList.Save();
					DefaultDeckStats.Load();
					DefaultDeckStats.Save();
					Helper.MainWindow.ShowMessage("Success", "Please restart HDT for this to take effect.");
				}
			}
		}
开发者ID:nikolasferreira,项目名称:Hearthstone-Deck-Tracker,代码行数:26,代码来源:TrackerBackups.xaml.cs

示例4: Update

 /// <summary>
 /// Downloads the specified web driver version.
 /// </summary>
 /// <param name="version">The version to download.</param>
 protected override void Update(string version)
 {
     using (var client = new WebClient())
     using (var stream = client.OpenRead("http://selenium-release.storage.googleapis.com/" + version + "/IEDriverServer_Win32_" + version + ".0.zip"))
     using (var archive = new ZipArchive(stream))
         archive.ExtractToDirectory(Path.Combine(ParentPath, version));
 }
开发者ID:stuartleeks,项目名称:BrowserBoss,代码行数:11,代码来源:InternetExplorerWebDriverSetup.cs

示例5: EmbeddedProcessTemplate

        public EmbeddedProcessTemplate(string processTemplateName)
        {
            _templatePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), processTemplateName + ".zip"))
                using (var archive = new ZipArchive(stream, ZipArchiveMode.Read))
                    archive.ExtractToDirectory(_templatePath);
        }
开发者ID:halvsvenskeren,项目名称:WitMorph,代码行数:8,代码来源:EmbeddedProcessTemplate.cs

示例6: LoadArchiveFromFile

 public static Archive LoadArchiveFromFile(Stream from, string dest)
 {
     if(!Directory.Exists(dest)) {
     Directory.CreateDirectory(dest);
       }
       var zip = new ZipArchive(from);
       zip.ExtractToDirectory(dest, true);
       return LoadArchiveFromDir(dest);
 }
开发者ID:svmnotn,项目名称:cuddly-octo-adventure,代码行数:9,代码来源:ArchiveManager.cs

示例7: BeforeFirstTest

        public virtual void BeforeFirstTest()
        {
            m_scratch.Create();

            using (var sampleDb = new MemoryStream( Properties.Resources.SampleDatabase ))
            using (var archive = new ZipArchive( sampleDb ))
                archive.ExtractToDirectory( m_scratch.FullName );

            Database.CreateOnce( Path.Combine( m_scratch.FullName, "movie.mdf" ) );
        }
开发者ID:JMS-1,项目名称:MovieDB,代码行数:10,代码来源:SampleDatabaseTestBase.cs

示例8: BtExtraerTodoClick

        private void BtExtraerTodoClick(object sender, EventArgs e)
        {
            const string rutaExtraido = @"C:\Tests\Extraidos\";

            using (var zip = new FileStream(RutaZip, FileMode.Open))
            {
                using (var archivo = new ZipArchive(zip, ZipArchiveMode.Update))
                {
                    archivo.ExtractToDirectory(rutaExtraido);
                }
            }
        }
开发者ID:joelgasso,项目名称:blogcodes,代码行数:12,代码来源:Form1.cs

示例9: ExtractSolution

        private static void ExtractSolution(string name, string destinationFolder)
        {
            var solutionArchivePath = Path.GetFullPath(name + ".zip");

            Assert.IsTrue(File.Exists(solutionArchivePath), "Test solution does not exist at {0}", solutionArchivePath);

            using (var solutionStream = File.OpenRead(solutionArchivePath))
            using (var archive = new ZipArchive(solutionStream, ZipArchiveMode.Read, true))
            {
                archive.ExtractToDirectory(destinationFolder);
            }
        }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:12,代码来源:PreviousVersionTests.cs

示例10: ResignScriptsInPackages

        private static void ResignScriptsInPackages(string packagePath, string outputPath)
        {
            var packages = Directory.EnumerateFiles(packagePath, "*.nupkg");

            foreach (var targetPackage in packages)
            {

                List<string> scriptPaths = new List<string>();
                using (FileStream stream = new FileStream(targetPackage, FileMode.Open))
                {
                    using (ZipArchive originalArchive = new ZipArchive(stream))
                    {
                        Console.WriteLine("{0}:", packagePath);
                        if (!originalArchive.Entries.Any(z => z.GetFileExtension().Contains("ps1")))
                        {
                            Console.WriteLine("No Powershell scripts found in {0}", targetPackage);
                            continue;
                        }

                        scriptPaths.AddRange(
                            originalArchive.Entries.Where(z => z.GetFileExtension().Contains("ps1"))
                                .Select(z => z.FullName));

                        var tempPath = Path.GetRandomFileName();
                        originalArchive.ExtractToDirectory(tempPath);

                        foreach (var script in scriptPaths)
                        {
                            var currentFile = Path.Combine(tempPath, script);
                            bool isSigned = Verifier.HasValidSignature(currentFile);
                            Console.WriteLine("{0} is {1}", currentFile, isSigned ? "signed" : "not signed");
                            if (!isSigned)
                            {
                                SignFile.SignFileFromDisk(currentFile);
                            }
                        }

                        var newPackageName = Path.GetFileName(targetPackage);
                        var outputPackagePath = Path.Combine(outputPath, newPackageName);

                        var parent = Path.GetDirectoryName(outputPackagePath);
                        if (!Directory.Exists(parent))
                        {
                            Directory.CreateDirectory(parent);
                        }
                        ZipFile.CreateFromDirectory(tempPath,outputPackagePath);

                    }
                }

            }
        }
开发者ID:voltagex,项目名称:iResign,代码行数:52,代码来源:Program.cs

示例11: NewLineInitialize

        public static void NewLineInitialize(TestContext testContext)
        {
            _testFolderPath = Path.Combine(Path.GetTempPath(), "TrimCopyTest");

            if (Directory.Exists(_testFolderPath))
                Directory.Delete(_testFolderPath, true);

            using (var ms = new MemoryStream(Properties.Resources.newLineInputOutput))
            using (var za = new ZipArchive(ms))
            {
                za.ExtractToDirectory(_testFolderPath);
            }
        }
开发者ID:emoacht,项目名称:TrimCopy,代码行数:13,代码来源:NewLineTypeTest.cs

示例12: UnZip

 public static void UnZip(string zipFile, string destPath=null)
 {
     if (destPath.IsNullOrWhiteSpace()) {
       FileInfo fi = new FileInfo(zipFile);
       destPath = fi.DirectoryName;
       }
       if (!Directory.Exists(destPath)) {
       Directory.CreateDirectory(destPath);
       }
       using (FileStream zipFileToOpen = new FileStream(zipFile, FileMode.Open))
       using (ZipArchive archive = new ZipArchive(zipFileToOpen, ZipArchiveMode.Update))
       archive.ExtractToDirectory(destPath);
 }
开发者ID:alittletired,项目名称:SolutionPlatform,代码行数:13,代码来源:ZipHelper.cs

示例13: extractZip

 private static void extractZip(ZipArchive zip, string destination, bool mapFilesInFolder)
 {
     if(mapFilesInFolder)
     {
         foreach(ZipArchiveEntry e in zip.Entries)
         {
             e.ExtractToFile(destination + "/" + e.Name);
         }
     }
     else
     {
         zip.ExtractToDirectory(destination);
     }
 }
开发者ID:BattlezoneUtilities,项目名称:BZLauncher,代码行数:14,代码来源:MapInstaller.cs

示例14: Completed

 private void Completed(object sender, AsyncCompletedEventArgs e)
 {
     label.Text = "Extracing";
     using (var fileStream = new FileStream("sai.zip", FileMode.Open))
     {
         using (var archive = new ZipArchive(fileStream, ZipArchiveMode.Read))
         {
             archive.ExtractToDirectory(Application.StartupPath, true);
         }
     }
     MessageBox.Show("Updated!");
     Process.Start("VisualSAIEditor.exe");
     Application.Exit();
 }
开发者ID:Jeidai,项目名称:VisualSAIStudio,代码行数:14,代码来源:MainForm.cs

示例15: Decompress

 // decompress
 // @return value: true(decomp), false(no need), null(error)
 public static bool? Decompress(string ArcPath)
 {
     // check
     switch(Path.GetExtension(ArcPath)){
         case ".bms":
         case ".bme":
         case ".bml":
             // Nothing
             Console.WriteLine("Archive Extract: No need.");
             // Move File
             File.Move(ArcPath, ExtractPath + Path.GetFileName(ArcPath));
             return false;
         case ".zip":
             // Zip archive
             var ZipArc = new ZipArchive(new FileStream(ArcPath, FileMode.Open));
             ZipArc.ExtractToDirectory(ExtractPath);
             Console.WriteLine("Archive Extract: Success(Type: Zip).");
             ZipArc.Dispose();
             return true;
         case ".rar":
             // Rar archive
             // Load Unrar.dll
             var rarMgr = new UnRarDllMgr();
             var UnrarPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\bin\\unrar64.dll";
             if(!rarMgr.LoadModule(UnrarPath)) {
                 // Error Message
                 Console.WriteLine("Error: Can't Load \"Unrar64.dll\"");
                 return null;
             }
             // Filelist get
             var FileLists = rarMgr.GetFileList(ArcPath);
             // All Extract
             foreach(var FileData in FileLists) {
                 rarMgr.FileExtractToFolder(ArcPath, FileData.FileNameW, ExtractPath);
             }
             Console.WriteLine("Archive Extract: Success(Type: Rar).");
             // Release Unrar.dll
             rarMgr.UnloadModule();
             rarMgr.CloseArchive();
             return true;
         default:
             // Error Message
             Console.WriteLine("Error: this extension({0}) is not supported.",
                 Path.GetExtension(ArcPath));
             return null;
     }
 }
开发者ID:Arika0093,项目名称:basd,代码行数:49,代码来源:decompress.cs


注:本文中的System.IO.Compression.ZipArchive.ExtractToDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。