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

 

 

 

 

 

 

Zip to Memory, Unzip from Memory

Download: Chilkat .NET Assemblies

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");
			}
		}

 

 

 

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

Email Component · XML Parser