Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Create Zip with Progress MonitoringDownload: Chilkat .NET Assemblies C# example program showing how to create a .zip with progress monitoring event callbacks. // Called by Zip.WriteZip, WriteZipAndClose, or WriteExe public void OnWriteZipPercentDone(object source, Chilkat.WriteZipPercentDoneEventArgs args) { progressBar1.Value = args.PercentDone; // To abort the Zip while in progress, set the Abort flag = true //args.Abort = true; } // Callback from with Zip.AppendFiles or Zip.AppendFilesEx public void OnDirToBeAdded(object source, Chilkat.DirToBeAddedEventArgs args) { // The directory may be excluded by settings args.Exclude = true //args.Exclude = true; listBox1.Items.Add(args.DirName); } // Callback from with Zip.AppendFiles or Zip.AppendFilesEx public void OnToBeAdded(object source, Chilkat.ToBeAddedEventArgs args) { listBox1.Items.Add(args.FileName); // The file may be excluded by setting args.Exclude = true //args.Exclude = true; } // Called during WriteZip, WriteZipAndClose, or WriteExe // This is called for each file/directory just before it is to be compressed // and written into the .zip. public void OnToBeZipped(object source, Chilkat.ToBeZippedEventArgs args) { listBox1.Items.Add(args.FileName + ": " + Convert.ToString(args.FileSize)); // The file may be excluded by setting args.Exclude = true //args.Exclude = true; } // Called during WriteZip, WriteZipAndClose, or WriteExe // This is called for each file/directory just after it is compressed // and written into the .zip. public void OnFileZipped(object source, Chilkat.FileZippedEventArgs args) { listBox1.Items.Add(args.FileName + ": " + Convert.ToString(args.CompressedSize) + " / " + Convert.ToString(args.FileSize)); } // Called at the beginning of a write Zip operation. // Applies to WriteZip, WriteZipAndClose, and WriteExe private void OnWriteZipBegin(object source, EventArgs args) { //MessageBox.Show("OnWriteZipBegin"); } // Called at the end of a write Zip operation. // Applies to WriteZip, WriteZipAndClose, and WriteExe private void OnWriteZipEnd(object source, EventArgs args) { //MessageBox.Show("OnWriteZipEnd"); } private void button2_Click(object sender, System.EventArgs e) { Chilkat.Zip zip = new Chilkat.Zip(); zip.UnlockComponent("trial"); zip.EnableEvents = true; zip.OnWriteZipBegin += new Chilkat.Zip.WriteZipBeginEventHandler(OnWriteZipBegin); zip.OnWriteZipEnd += new Chilkat.Zip.WriteZipEndEventHandler(OnWriteZipEnd); zip.OnDirToBeAdded += new Chilkat.Zip.DirToBeAddedEventHandler(OnDirToBeAdded); zip.OnToBeAdded += new Chilkat.Zip.ToBeAddedEventHandler(OnToBeAdded); zip.OnFileZipped += new Chilkat.Zip.FileZippedEventHandler(OnFileZipped); zip.OnToBeZipped += new Chilkat.Zip.ToBeZippedEventHandler(OnToBeZipped); zip.OnWriteZipPercentDone += new Chilkat.Zip.WriteZipPercentDoneEventHandler(OnWriteZipPercentDone); zip.NewZip("test.zip"); zip.AppendFromDir = "c:/temp/"; // Zip the entire "abc" subdirectory zip.AppendFiles("abc/*",true); listBox1.Items.Add("AppendFiles COMPLETE"); progressBar1.Value = 0; //Write the zip with callback events. bool success = zip.WriteZipAndClose(); } Important: The download for this
example does not contain the ChilkatDotNet.dll which |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.