Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Open Zip from Image in Memory
Opens a Zip file from memory and unzips the first file. An image of the Zip file is in-memory, and this is opened as if it were a file on disk. private void button1_Click(object sender, System.EventArgs e)
{
// Make the byte array big enough to hold the file
int iSize = 500000;
// loading data to memory - emulating data gathered from network
System.IO.FileStream fs = new System.IO.FileStream("test.zip",
System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] b = new byte[iSize];
fs.Read(b, 0, iSize);
fs.Close();
// Create the Zip object and unlock it.
Chilkat.Zip zip = new Chilkat.Zip();
zip.FileName = "anything.zip";
zip.UnlockComponent("30-day trial");
// Open the Zip from memory
bool openSuccess = zip.OpenFromMemory(b);
if (openSuccess)
{
// Display the start time.
label1.Text = DateTime.Now.ToLongTimeString();
label1.Refresh();
// Inflate the 1st file in the Zip.
byte [] c = zip.FirstEntry().Inflate();
// Display the end time.
label2.Text = DateTime.Now.ToLongTimeString();
label2.Refresh();
// writing file to disk
fs = new System.IO.FileStream(zip.FirstEntry().FileName, System.IO.FileMode.OpenOrCreate,
System.IO.FileAccess.Write);
fs.Write(c, 0, c.Length);
fs.Close();
}
else
{
// Display error message.
textBox1.Text = zip.LastErrorText;
}
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.