- fileName (String)
- The name of the file to add or update. It should refer to a file in the filesystem. The name of the file may be a relative path or a fully-qualified path.
This method adds a file to a zip archive, or, if the file already exists in the zip archive, this method Updates the content of that given filename in the zip archive. The UpdateFile method might more accurately be called "AddOrUpdateFile".
Upon success, there is no way for the application to learn whether the file was added versus updated.
For ZipFile properties including Encryption, Password, SetCompression, ProvisionalAlternateEncoding, ExtractExistingFile, ZipErrorAction, and CompressionLevel, their respective values at the time of this call will be applied to the ZipEntry added.
using (ZipFile zip1 = new ZipFile()) { // UpdateFile might more accurately be called "AddOrUpdateFile" zip1.UpdateFile("MyDocuments\\Readme.txt"); zip1.UpdateFile("CustomerList.csv"); zip1.Comment = "This zip archive has been created."; zip1.Save("Content.zip"); } using (ZipFile zip2 = ZipFile.Read("Content.zip")) { zip2.UpdateFile("Updates\\Readme.txt"); zip2.Comment = "This zip archive has been updated: The Readme.txt file has been changed."; zip2.Save(); }
Using zip1 As New ZipFile ' UpdateFile might more accurately be called "AddOrUpdateFile" zip1.UpdateFile("MyDocuments\Readme.txt") zip1.UpdateFile("CustomerList.csv") zip1.Comment = "This zip archive has been created." zip1.Save("Content.zip") End Using Using zip2 As ZipFile = ZipFile.Read("Content.zip") zip2.UpdateFile("Updates\Readme.txt") zip2.Comment = "This zip archive has been updated: The Readme.txt file has been changed." zip2.Save End Using