本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.FastZip.ExtractZip方法的典型用法代码示例。如果您正苦于以下问题:C# FastZip.ExtractZip方法的具体用法?C# FastZip.ExtractZip怎么用?C# FastZip.ExtractZip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Zip.FastZip
的用法示例。
在下文中一共展示了FastZip.ExtractZip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractZipArchive
private static bool ExtractZipArchive(string archive, string destination, FastZip fz)
{
DirectoryInfo newdirFI;
if (!Directory.Exists(destination))
{
newdirFI = Directory.CreateDirectory(destination);
if (!Directory.Exists(newdirFI.FullName))
{
//MessageBox.Show("Directory " + destination + " could not be created.");
return false;
}
}
else newdirFI = new DirectoryInfo(destination);
try
{
Thread.Sleep(500);
fz.ExtractZip(archive, newdirFI.FullName, "");
}
catch (Exception e)
{
Debugger.LogMessageToFile("The archive " + archive + " could not be extracted to destination " + destination +
". The following error ocurred: " + e);
}
return true;
}
示例2: CreateDeltaPackage
public ReleasePackage CreateDeltaPackage(ReleasePackage basePackage, ReleasePackage newPackage, string outputFile)
{
Contract.Requires(basePackage != null);
Contract.Requires(!String.IsNullOrEmpty(outputFile) && !File.Exists(outputFile));
if (basePackage.Version > newPackage.Version) {
var message = String.Format(
"You cannot create a delta package based on version {0} as it is a later version than {1}",
basePackage.Version,
newPackage.Version);
throw new InvalidOperationException(message);
}
if (basePackage.ReleasePackageFile == null) {
throw new ArgumentException("The base package's release file is null", "basePackage");
}
if (!File.Exists(basePackage.ReleasePackageFile)) {
throw new FileNotFoundException("The base package release does not exist", basePackage.ReleasePackageFile);
}
if (!File.Exists(newPackage.ReleasePackageFile)) {
throw new FileNotFoundException("The new package release does not exist", newPackage.ReleasePackageFile);
}
string baseTempPath = null;
string tempPath = null;
using (Utility.WithTempDirectory(out baseTempPath, null))
using (Utility.WithTempDirectory(out tempPath, null)) {
var baseTempInfo = new DirectoryInfo(baseTempPath);
var tempInfo = new DirectoryInfo(tempPath);
this.Log().Info("Extracting {0} and {1} into {2}",
basePackage.ReleasePackageFile, newPackage.ReleasePackageFile, tempPath);
var fz = new FastZip();
fz.ExtractZip(basePackage.ReleasePackageFile, baseTempInfo.FullName, null);
fz.ExtractZip(newPackage.ReleasePackageFile, tempInfo.FullName, null);
// Collect a list of relative paths under 'lib' and map them
// to their full name. We'll use this later to determine in
// the new version of the package whether the file exists or
// not.
var baseLibFiles = baseTempInfo.GetAllFilesRecursively()
.Where(x => x.FullName.ToLowerInvariant().Contains("lib" + Path.DirectorySeparatorChar))
.ToDictionary(k => k.FullName.Replace(baseTempInfo.FullName, ""), v => v.FullName);
var newLibDir = tempInfo.GetDirectories().First(x => x.Name.ToLowerInvariant() == "lib");
foreach (var libFile in newLibDir.GetAllFilesRecursively()) {
createDeltaForSingleFile(libFile, tempInfo, baseLibFiles);
}
ReleasePackage.addDeltaFilesToContentTypes(tempInfo.FullName);
fz.CreateZip(outputFile, tempInfo.FullName, true, null);
}
return new ReleasePackage(outputFile);
}
示例3: Main
private static void Main(string[] args)
{
if (args.Length != 3)
{
Console.Error.WriteLine("Error: not enough arguments");
Console.Error.WriteLine("Usage: MetroIdeUpdateManager <update zip> <metroide exe> <parent pid>");
return;
}
string zipPath = args[0];
string exePath = args[1];
int pid = Convert.ToInt32(args[2]);
try
{
// Wait for Assembly to close
try
{
Process process = Process.GetProcessById(pid);
process.WaitForExit();
process.Close();
}
catch
{
}
// Extract the update zip
var fz = new FastZip {CreateEmptyDirectories = true};
for (int i = 0; i < 5; i++)
{
try
{
fz.ExtractZip(zipPath, Directory.GetCurrentDirectory(), null);
break;
}
catch (IOException)
{
Thread.Sleep(1000);
if (i == 4)
{
throw;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Assembly Update Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
File.Delete(zipPath);
}
catch
{
}
// Launch "The New iPa... Assembly"
Process.Start("Assembly://post-update");
}
示例4: GetFile
private void GetFile()
{
var exctractfolder = _localFile.DirectoryName.ToString() + @"\exctract\";
DownloadFile(_localFile.FullName);
var zip = new FastZip();
zip.ExtractZip(_localFile.FullName, exctractfolder, "");
}
示例5: UnzipNewAgentVersion
private void UnzipNewAgentVersion()
{
_logger.Log("Unzipping files");
var fz = new FastZip();
fz.ExtractZip(Constants.AgentServiceReleasePackage, Constants.AgentServiceUnzipPath, "");
_logger.Log("Unzipping files complete");
}
开发者ID:rackerlabs,项目名称:openstack-guest-agents-windows-xenserver-old,代码行数:7,代码来源:InstallAgentService.cs
示例6: UnzipProject
/// <summary>
///
/// </summary>
/// <param name="filename"></param>
/// <returns>temporary project file name.</returns>
public string UnzipProject(string filename)
{
output = null;
// Check File
if (!File.Exists(filename))
throw new EcellException(string.Format(MessageResources.ErrLoadPrj, filename));
// Extract zip
string dir = Path.Combine(Util.GetTmpDir(), Path.GetRandomFileName());
FastZip fz = new FastZip();
fz.ExtractZip(filename, dir, null);
// Check Project File.
string project = Path.Combine(dir,Constants.fileProjectXML);
string info = Path.Combine(dir,Constants.fileProjectInfo);
if(File.Exists(project))
output = project;
else if(File.Exists(info))
output = info;
if (output == null)
{
Directory.Delete(dir);
throw new EcellException(string.Format(MessageResources.ErrLoadPrj, filename));
}
// Return project path.
return output;
}
示例7: DownloadAndUpdateSnakeBite
private static void DownloadAndUpdateSnakeBite(string URL)
{
// Download update archive
using (WebClient w = new WebClient()) w.DownloadFile(URL, "update.dat");
// Extract archive
FastZip z = new FastZip();
z.ExtractZip("update.dat", "_update", "(.*?)");
// Move update file
File.Delete("SnakeBite.exe");
File.Delete("MakeBite.exe");
File.Delete("GzsTool.Core.dll");
File.Delete("fpk_dictionary.txt");
File.Delete("qar_dictionary.txt");
File.Move("_update/SnakeBite.exe", "SnakeBite.exe");
File.Move("_update/MakeBite.exe", "MakeBite.exe");
File.Move("_update/GzsTool.Core.dll", "GzsTool.Core.dll");
File.Move("_update/fpk_dictionary.txt", "fpk_dictionary.txt");
File.Move("_update/qar_dictionary.txt", "qar_dictionary.txt");
// Restart updater
Process updater = new Process();
updater.StartInfo.Arguments = "-u";
updater.StartInfo.UseShellExecute = false;
updater.StartInfo.FileName = "sbupdater.exe";
updater.Start();
Environment.Exit(0);
}
示例8: UnZipFile
/// <summary>
/// 解压zip文件
/// </summary>
/// <param name="_zipFile">需要解压的zip路径+名字</param>
/// <param name="_outForlder">解压路径</param>
public void UnZipFile(string _zipFile, string _outForlder)
{
if (Directory.Exists(_outForlder))
Directory.Delete(_outForlder, true);
Directory.CreateDirectory(_outForlder);
progress = progressOverall = 0;
Thread thread = new Thread(delegate ()
{
int fileCount = (int)new ZipFile(_zipFile).Count;
int fileCompleted = 0;
FastZipEvents events = new FastZipEvents();
events.Progress = new ProgressHandler((object sender, ProgressEventArgs e) =>
{
progress = e.PercentComplete;
if (progress == 100) { fileCompleted++; progressOverall = 100 * fileCompleted / fileCount; }
});
events.ProgressInterval = TimeSpan.FromSeconds(progressUpdateTime);
events.ProcessFile = new ProcessFileHandler(
(object sender, ScanEventArgs e) => { });
FastZip fastZip = new FastZip(events);
fastZip.ExtractZip(_zipFile, _outForlder, "");
});
thread.IsBackground = true;
thread.Start();
}
示例9: unZIP
public static void unZIP(string srcZip, string detDir)
{
string filename = Path.GetFileNameWithoutExtension(srcZip);
if (detDir == string.Empty)
{
detDir = srcZip.Substring(0,srcZip.LastIndexOf("\\"));
}
detDir = detDir + "\\" + filename;
if (!Directory.Exists(detDir))
{
Directory.CreateDirectory(detDir);
}
FastZip fastzip = new FastZip();
//// Create Empty Directory
fastzip.CreateEmptyDirectories = true;
try
{
fastzip.ExtractZip(srcZip, detDir, string.Empty);
//MessageBox.Show("ok");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
示例10: setDbfInfoFromZip
private void setDbfInfoFromZip(string dbfPath)
{
try
{
//Navigate the Zip to find the files and update their index
ZipFile zFile = new ZipFile(dbfPath);
foreach (ZipEntry ze in zFile)
{
if(ze.Name.ToLower().EndsWith(".dbf"))
{
//Extracts the file in temp
FastZip fz = new FastZip();
fz.ExtractZip(dbfPath, Path.GetTempPath(),
ICSharpCode.SharpZipLib.Zip.FastZip.Overwrite.Always,null,"","");
setDbfInfo(Path.Combine(Path.GetTempPath(),ze.Name));
}
}
}
catch { return; }
//TODO: read the sbf data into the datagrid
//DataTable dt=getInfoFromDBF(dbfPath);
//dataGrid1.DataSource=dt;
//dataGrid1.CaptionText=dbfPath;
}
示例11: ExtractZipFile
public static void ExtractZipFile(string zipFile, string outputFolder) {
FastZip fastZip = new FastZip();
try {
fastZip.ExtractZip(zipFile, outputFolder, null); // Will always overwrite if target filenames already exist
} catch (Exception ex) {
Logger.Error("Extracting Zip failed.", ex);
}
}
示例12: ExtractZip
public static bool ExtractZip(string filename, string directory)
{
FastZip fz = new FastZip();
fz.CreateEmptyDirectories = true;
fz.ExtractZip(filename, directory, "");
fz = null;
return true;
}
示例13: UnZip
public void UnZip()
{
string zipPath = "D:/Test.zip";
string zipDir = "D:/Test2/";
FastZip fastZip = new FastZip();
fastZip.ExtractZip(zipPath, zipDir, null);
}
示例14: Unzip
public static void Unzip(string directory, string zip)
{
var package = new FastZip
{
CreateEmptyDirectories = true
};
package.ExtractZip(zip, directory, String.Empty);
}
示例15: unZip
public void unZip()
{
string zipFileName = @"..\..\..\Sample-Sales-Reports.zip"; // change
var targetDir = @"..\..\..\Excel";
FastZip fastZip = new FastZip();
string fileFilter = null;
// Will always overwrite if target filenames already exist
fastZip.ExtractZip(zipFileName, targetDir, fileFilter);
}