本文整理汇总了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);
}
}
示例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));
}
示例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.");
}
}
}
示例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));
}
示例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);
}
示例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);
}
示例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" ) );
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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;
}
}