- fileName (String)
- The name of the zip archive to save to. Existing files will be overwritten with great prejudice.
This method allows the application to explicitly specify the name of the zip file when saving. Use this when creating a new zip file, or when updating a zip archive.
An application can also save a zip archive in several places by calling this method multiple times in succession, with different filenames.
The ZipFile instance is written to storage, typically a zip file in a filesystem, only when the caller calls Save. The Save operation writes the zip content to a temporary file, and then renames the temporary file to the desired name. If necessary, this method will delete a pre-existing file before the rename.
using (ZipFile zip = new ZipFile()) { zip.AddDirectory(@"c:\reports\January"); zip.Save("January.zip"); }
Using zip As New ZipFile() zip.AddDirectory("c:\reports\January") zip.Save("January.zip") End Using
using (ZipFile zip = ZipFile.Read("ExistingArchive.zip")) { zip.AddFile("NewData.csv"); zip.Save("UpdatedArchive.zip"); }
Using zip As ZipFile = ZipFile.Read("ExistingArchive.zip") zip.AddFile("NewData.csv") zip.Save("UpdatedArchive.zip") End Using
Exception | Condition |
---|---|
ArgumentException |
Thrown if you specify a directory for the filename.
|