C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

Create Zip with Progress Monitoring

Download: 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
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/csharp/step2.asp

 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Email Component · XML Parser