[]
        
(Showing Draft Content)

C1.Zip.C1ZipFile.Create

Create Method

Create(string)

Creates an empty zip file on disk.

Declaration
public void Create(string fileName)
Parameters
Type Name Description
string fileName

The name of the zip file to create, including the path.

Remarks

If a file by the same name already exists, it is deleted before the new one is created.

Create(Stream)

Creates a new zip file in a stream.

Declaration
public void Create(Stream stream)
Parameters
Type Name Description
Stream stream

Stream that will contain the new zip file.

Examples

The code below creates a new C1ZipFile on a memory stream, then adds several files to it. Finally, the code gets the zipped data out as an array of bytes, which could be stored in a database for example.

// create zip on a stream
MemoryStream msZip = new MemoryStream();
C1ZipFile zip = new C1ZipFile(msZip, true);

// add some entries to it
foreach (string f in Directory.GetFiles(@"c:\WINDOWS\Web\Wallpaper"))
{
  zip.Entries.Add(f);
}

// get zipped data out as a byte array
byte[] zipData = msZip.ToArray();