Exemplo n.º 1
0
    public static void UnzipAsync(string fileName,
                                  string targetDir,
                                  ICSharpCode.SharpZipLib.Core.TotalProgressHandler hTotalProgress = null,
                                  ICSharpCode.SharpZipLib.Core.TotalFinishHandler hTotalFinish     = null)
    {
        ICSharpCode.SharpZipLib.Zip.FastZipEvents2 events = new ICSharpCode.SharpZipLib.Zip.FastZipEvents2();
        events.TotalProgress    = hTotalProgress;
        events.TotalFinish      = hTotalFinish;
        events.Progress         = ProgressHandler;
        events.ProgressInterval = TimeSpan.FromSeconds(0.5);

        mZip2      = new ICSharpCode.SharpZipLib.Zip.FastZip2(events);
        mZipFile   = fileName;
        mTargetDir = targetDir;

        Thread th = new Thread(StartUnzipFile);

        th.IsBackground = true;
        th.Start();
    }
Exemplo n.º 2
0
    public static void Unzip(Stream zipStream,
                             string targetDir,
                             ICSharpCode.SharpZipLib.Core.TotalProgressHandler hTotalProgress       = null,
                             ICSharpCode.SharpZipLib.Core.ProcessDirectoryHandler hProcessDirectory = null,
                             ICSharpCode.SharpZipLib.Core.ProcessFileHandler hProcessFile           = null,
                             ICSharpCode.SharpZipLib.Core.ProgressHandler hProgress                 = null,
                             ICSharpCode.SharpZipLib.Core.CompletedFileHandler hCompletedFile       = null,
                             ICSharpCode.SharpZipLib.Core.DirectoryFailureHandler hDirectoryFailure = null,
                             ICSharpCode.SharpZipLib.Core.FileFailureHandler hFileFailure           = null)
    {
        ICSharpCode.SharpZipLib.Zip.FastZipEvents2 events = new ICSharpCode.SharpZipLib.Zip.FastZipEvents2();
        events.TotalProgress    = hTotalProgress;
        events.ProcessDirectory = hProcessDirectory;
        events.ProcessFile      = hProcessFile;
        events.Progress         = hProgress;
        events.CompletedFile    = hCompletedFile;
        events.DirectoryFailure = hDirectoryFailure;
        events.FileFailure      = hFileFailure;
        events.ProgressInterval = TimeSpan.FromSeconds(0.5);

        mZip2 = new ICSharpCode.SharpZipLib.Zip.FastZip2(events);
        mZip2.ExtractZip(zipStream, targetDir, ICSharpCode.SharpZipLib.Zip.FastZip2.Overwrite.Always, null, null, null, true, true);
    }