Save Method (fileName)

DotNetZip

Ionic Zip Library v1.9.1.6 Save Method (fileName)
ReferenceIonic.ZipZipFileSave(String)
Save the file to a new zipfile, with the given name.
Declaration Syntax
C# Visual Basic Visual C++
public void Save(
	string fileName
)
Public Sub Save ( _
	fileName As String _
)
public:
void Save(
	String^ fileName
)
Parameters
fileName (String)
The name of the zip archive to save to. Existing files will be overwritten with great prejudice.
Remarks

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.

Examples
This example shows how to create and Save a zip file.
CopyC#
using (ZipFile zip = new ZipFile())
{
  zip.AddDirectory(@"c:\reports\January");
  zip.Save("January.zip");
}
CopyVB.NET
Using zip As New ZipFile()
  zip.AddDirectory("c:\reports\January")
  zip.Save("January.zip")
End Using
Examples
This example shows how to update a zip file.
CopyC#
using (ZipFile zip = ZipFile.Read("ExistingArchive.zip"))
{
  zip.AddFile("NewData.csv");
  zip.Save("UpdatedArchive.zip");
}
CopyVB.NET
Using zip As ZipFile = ZipFile.Read("ExistingArchive.zip")
  zip.AddFile("NewData.csv")
  zip.Save("UpdatedArchive.zip")
End Using
Exceptions
Exception Condition
ArgumentException Thrown if you specify a directory for the filename.

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)