Страница:
Zip Samples
Страницы
Code Reference
Create a Zip as a browser download attachment in IIS
Create a Zip from to a memory stream or byte array
Create a Zip with full control over content
Download and Unpack a zip from an FTP server with recovery
FAQ
FastZip
GZip and Tar Samples
Home
Joining the Team
Links
Release 1.0
Release 1.1
Release 1.2
Release 1.3.1
Release 1.3.2
Release 1.3.3
Release 1.3
Release 1.4.0
Release 1.4.1
Release 1.4.2
Release History
Unpack a Zip, including embedded zips, and re pack into a new zip or memorystream
Unpack a Zip with full control over the operation
Unpack a zip using ZipInputStream
Updating
Zip Samples
ZipStrings and Unicode
17
Zip Samples
nils måsén редактировал(а) эту страницу 2020-08-16 12:00:45 +02:00
Code Reference / Zip Samples
How to use SharpZipLib to work with Zip files
These samples try to cover the range of situations you will encounter. You may need to combine parts of each sample for your application.
General usage
- Create a Zip with full control over content
- Create a Zip from/to a memory stream or byte array
- Unpack a Zip with full control over the operation
- Unpack a zip using ZipInputStream (eg for Unseekable input streams)
Specific usage
- Unpack a Zip, including embedded zips, and re-pack into a new zip or memorystream
- Download and Unpack a zip from an FTP server with recovery
- Create a Zip as a browser download attachment in IIS
Short examples
Create a Zip from a HTML string (C#)
string htmlData = ...
using (var fs = File.Create("html-archive.zip"))
using (var outStream = new ZipOutputStream(fs))
{
outStream.PutNextEntry(new ZipEntry("content.html"));
using (var sw = new StreamWriter(outStream))
{
sw.Write(htmlData);
}
}
Create a Zip from a byte array (C#)
var dataBytes = new byte[] { 0x49, 0xe2, 0x9d, 0xa4, 0x5a, 0x49, 0x50 };
using (var fs = File.Create("data.zip"))
using (var outStream = new ZipOutputStream(fs))
{
outStream.PutNextEntry(new ZipEntry("data.bin"));
outStream.Write(dataBytes);
}