C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

C# Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
String
Byte Array
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

Zip to Memory, Unzip from Memory

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

This C# sample program demonstrates zipping and unzipping from memory.

		public static byte[] StrToByteArray(string str)
		{
			System.Text.ASCIIEncoding  encoding=new System.Text.ASCIIEncoding();
			return encoding.GetBytes(str);
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			Chilkat.Zip zip = new Chilkat.Zip();
			zip.UnlockComponent("30-day trial");

			// Initialize the Zip object.  This does not create a file on disk.
			zip.NewZip("test.zip");

			// Generate some data.
			String fileContents = "Test\n";
			int i;
			for (i=0; i<100; i++)
			{
				fileContents = fileContents + "This is a test 1234\n";
			}
			byte [] byteData = StrToByteArray(fileContents);

			textBox1.Text = "uncompressed data size = " + byteData.Length + "\r\n";

			// Append this data to the Zip object.
			zip.AppendData("test.txt",byteData);

			// Get the compressed data.
			Chilkat.ZipEntry entry;

			// The first entry is what we just appended.
			entry = zip.FirstEntry();

			// Copy the compressed data without decompressing it.
			byte [] compressedData = entry.Copy();

			textBox1.Text = textBox1.Text + "compressed data size = " + compressedData.Length + "\r\n";

			// ...
			// Send the compressed data over a network connection, for example...
			// ...

			// This could be the code in another program that receives
			// the compressed data.
			Chilkat.Zip zip2 = new Chilkat.Zip();

			// Initialize the Zip object.  This does not create a file on disk.
			zip2.NewZip("test.zip");

			// Append the already-compressed data.
			zip2.AppendCompressed("test.txt",compressedData);

			// Extract it to a file named "test.txt" in the current directory.
			bool success;
			success = zip2.Extract(".");
			if (!success)
			{
				MessageBox.Show(zip2.LastErrorText);
			}
			else
			{
				MessageBox.Show("Extracted to test.txt");
			}
		}

 

 

 

Need a specific example? Send a request to support@chilkatsoft.com

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

Email Component · XML Parser