本文整理汇总了C#中Ionic.Zip.ZipFile.ExtractAll方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.ExtractAll方法的具体用法?C# ZipFile.ExtractAll怎么用?C# ZipFile.ExtractAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zip.ZipFile
的用法示例。
在下文中一共展示了ZipFile.ExtractAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
using (var Site = new SPSite("http://epm2007demo/pwa04"))
{
SPList List = Site.RootWeb.Lists["Shared Documents"];
foreach (SPListItem item in List.Items)
{
if (item.FileSystemObjectType == SPFileSystemObjectType.File)
{
byte[] bytes = item.Folder.Files[0].OpenBinary();
var writer = new FileStream("c:\\text.docx", FileMode.OpenOrCreate);
writer.Write(bytes, 0, bytes.Length);
writer.Flush();
writer.Close();
}
}
}
return;
using (var zip = new ZipFile(@"C:\Documents and Settings\Administrator\Desktop\ITXWorkflowAppDeployment\Batch_Installer.zip"))
{
zip.ExtractAll(Environment.ExpandEnvironmentVariables("%temp%"));
}
return;
foreach (var directory in Directory.GetDirectories(@"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"))
{
string[] dirs = directory.Split('\\');
string curdir = dirs[dirs.Length - 1];
}
return;
}
示例2: Main
static void Main(string[] args)
{
var cwd = Environment.CurrentDirectory;
//stop the agent service
RunProcess(" /c \"Agent.exe stop\" ");
Console.WriteLine("agent stopped");
Console.WriteLine(cwd);
foreach (var file in Directory.EnumerateFiles(cwd).Where(x => !x.Contains("update.zip") && !x.Contains("Updater.exe") && !x.Contains("Ionic.Zip.dll"))){
Console.WriteLine("deleteing "+file);
File.Delete(file);
}
//extract the new version
using (var zip = new ZipFile(Path.Combine(cwd, "update.zip")))
{
zip.TempFileFolder = System.IO.Path.GetTempPath();
zip.ExtractAll(cwd, ExtractExistingFileAction.OverwriteSilently);
}
Console.WriteLine("files extracted");
//clean update package
System.IO.File.Delete(Path.Combine(cwd, "update.zip"));
//start the agent service again
RunProcess(" /c \"Agent.exe start\" ");
}
示例3: ExtractArchive
/// <summary>
/// Extracts the contents of the input archive and outputs its contents to the specified outputDirectoryPath
/// </summary>
public void ExtractArchive(string inputArchivePath, string outputDirectoryPath)
{
using (ZipFile zipFile = new ZipFile(inputArchivePath))
{
zipFile.ExtractAll(outputDirectoryPath);
}
}
示例4: UnzipFilesWithManifest
/// <summary>
/// Given the target folder, it will unzip any zips, and then send folders with imsmanifest.xml into manifest parser.
/// </summary>
/// <param name="topDirectory"></param>
/// <param name="reportFile"></param>
public static void UnzipFilesWithManifest(string topDirectory)
{
string[] zipsList = Directory.GetFiles(topDirectory, "*.zip");
string extractionDestination;
// Extract zips --------------------------------------------------------------------------------
if (zipsList.Length > 0)
{
Console.WriteLine("---------- EXTRACTING ZIPS ----------\n");
for (int i = 0; i < zipsList.Length; i++)
{
ZipFile zipFolder = new ZipFile(zipsList[i]);
// Generate extact folder name
extractionDestination = zipFolder.Name.Replace(".zip", "");
// If that folder already exists, skip
if (!Directory.Exists(extractionDestination))
{
Console.WriteLine("About to extract " + zipFolder.Name);
// If the zipFile doesn't have the manifest, don't extract. There won't be a manifest to parse
if (zipFolder.ContainsEntry("imsmanifest.xml"))
{
zipFolder.ExtractAll(extractionDestination);
Console.WriteLine("\tExtracted " + zipFolder.Name + "\n");
}
else
{
Console.WriteLine("\tManifest file was not found\n");
}
}
}
Console.WriteLine("---------- FINISHED EXTRACTING ZIPS ----------\n\n");
}
}
示例5: unzip
public static void unzip(string zipFileName, string outputDirectory)
{
Console.WriteLine("Unzipping '{0}' to '{1}'", zipFileName, outputDirectory);
using (var zip = new ZipFile(zipFileName)) {
zip.ExtractAll(outputDirectory);
}
}
示例6: Extract
public static void Extract(string directoryName)
{
if (Directory.Exists(directoryName))
{
try
{
var archiveNameNoExtension = Path.Combine(directoryName, new DirectoryInfo(directoryName).Name);
var archiveName = Path.Combine(archiveNameNoExtension, "zip");
using (var zip = new ZipFile(archiveName))
{
zip.ExtractProgress += (s, e) =>
{
var filePercentage = e.EntriesExtracted / e.EntriesTotal * 100;
};
zip.ExtractAll(directoryName);
}
}
catch (Exception ex)
{
Logging.Logger.Log(Logging.SeverityGrades.Warning, string.Format("Archive extraction failed: {0}", ex.Message));
}
}
}
示例7: Extract
public void Extract(string destinationFolderPath)
{
using (var zip = new ZipFile(this.Path))
{
zip.ExtractAll(destinationFolderPath, this.ExtractionStrategy);
}
}
示例8: extract_all_to_fldr
public bool extract_all_to_fldr(string archive_path, string destination_path)
{
if (archive_path != "" & File.Exists(archive_path))
{
if (Directory.Exists(destination_path) == false) { Directory.CreateDirectory(destination_path); };
try
{
using (ZipFile zip1 = new ZipFile(archive_path))
{
zip1.ExtractAll(destination_path, ExtractExistingFileAction.OverwriteSilently);
}
}
catch (Exception exc1)
{
MessageBox.Show(String.Format("Ошибка при разархивировании zip-файла", exc1.Message));
return false;
// throw;
}
return true;
}
else
{
return false;
}
}
示例9: OnExecute
/// <summary>
/// Do the unzip.
/// </summary>
protected override void OnExecute(ServerCommandProcessor theProcessor)
{
using (ZipFile zip = new ZipFile(_zipFile))
{
zip.ExtractAll(_destinationFolder,_overwrite);
}
}
示例10: bgWorker_Finish
private void bgWorker_Finish(object sender, RunWorkerCompletedEventArgs e)
{
dlElapsedTimer.Stop();
try
{
if (File.Exists(zipTarget))
{
using (ZipFile zip = new ZipFile(zipTarget))
{
zip.ExtractAll(Directory.GetCurrentDirectory(), ExtractExistingFileAction.OverwriteSilently);
zip.Dispose();
}
File.Delete(zipTarget);
Process start = new Process();
start.StartInfo.FileName = exeTarget;
start.StartInfo.Arguments = "ProcessStart.cs";
start.Start();
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show("There was an error with the updater. Check your connection and try running as an administrator.\r\n\r\n" + ex.Message);
Application.Exit();
}
}
示例11: ExtrairArquivoZip
/// <summary>
/// Extraindo informações do "Zip" e colocando na pasta do software.
/// </summary>
/// <param name="localizacaoArquivoZip"></param>
/// <param name="destino"></param>
public void ExtrairArquivoZip(string localizacaoArquivoZip, string destino)
{
if (File.Exists(localizacaoArquivoZip))
{
//recebe a localização do arquivo zip
ZipFile zip = new ZipFile(localizacaoArquivoZip);
{
//verifica se o destino existe
if (Directory.Exists(destino))
{
try
{
//extrai o arquivo zip para o destino
zip.ExtractAll(destino);
}
catch
{
}
}
else
{
//lança uma exceção se o destino não existe
throw new DirectoryNotFoundException("O arquivo destino não foi localizado");
}
}
}
else
{
//lança uma exceção se a origem não existe
throw new FileNotFoundException("O Arquivo Zip não foi localizado");
}
}
示例12: ExtractTemplate
protected virtual void ExtractTemplate()
{
string zipPath = Path.Combine(ProjectBuilder.ZipFileFolder, ProjectTemplateFile);
using (ZipFile zipFile = new ZipFile(zipPath))
{
zipFile.ExtractAll(ProjectDirectory, ExtractExistingFileAction.DoNotOverwrite);
}
}
示例13: GivenIUnzipThatPackageIntoADeploymentFolder
public void GivenIUnzipThatPackageIntoADeploymentFolder()
{
var folder = (string)ScenarioContext.Current["targetFolder"];
if (Directory.Exists(folder))
Directory.Delete(folder, true);
var zip = new ZipFile((string)ScenarioContext.Current["targetZip"]);
zip.ExtractAll(folder);
zip.Dispose();
}
示例14: ExtractFile
public void ExtractFile(string zipPath, string targetDirectory)
{
using(var zipFile = new ZipFile(zipPath))
{
_logger.Debug(string.Format("Extracting file {0} to directory {1}", zipPath, targetDirectory));
zipFile.ExtractAll(targetDirectory);
_logger.Debug(string.Format("Done extracting file {0} to to directory {1}", zipPath, targetDirectory));
}
}
示例15: ExtractXapToTempLocation
private static void ExtractXapToTempLocation(string xapLocation, string pathtoExtractAssembliesTo)
{
if (Directory.Exists(pathtoExtractAssembliesTo)) Directory.Delete(pathtoExtractAssembliesTo, true);
Directory.CreateDirectory(pathtoExtractAssembliesTo);
using (var file = new ZipFile(xapLocation))
{
file.ExtractAll(pathtoExtractAssembliesTo, ExtractExistingFileAction.OverwriteSilently);
}
}