Ionic.Zip.ZipFile.UpdateFile C# (CSharp) Method

UpdateFile() public method

Adds or Updates a File in a Zip file archive.

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, , SetCompression, , ExtractExistingFile, ZipErrorAction, and CompressionLevel, their respective values at the time of this call will be applied to the ZipEntry added.

public UpdateFile ( string fileName ) : ZipEntry
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. ///
return ZipEntry
        public ZipEntry UpdateFile(string fileName)
        {
            return UpdateFile(fileName, null);
        }

Same methods

ZipFile::UpdateFile ( string fileName, String directoryPathInArchive ) : ZipEntry

Usage Example

Esempio n. 1
0
		/// <summary>Copy all the files in the TOC to the all the destination zips</summary>
		/// <param name="TableOfContents">Container for all the files to copy</param>
		public static void ZipFiles( TOC TableOfContents )
		{
			// Handle zips
			if( Options.ZipName.Length > 0 )
			{
				long TotalFilesZipped = TableOfContents.Entries.Count;
				long TotalBytesZipped = TableOfContents.Entries.Sum( x => x.Info.Length );

				ZipFile Zip = new ZipFile( Options.ZipName );
				Zip.CompressionLevel = Ionic.Zlib.CompressionLevel.Level9;
				Zip.UseZip64WhenSaving = Zip64Option.Always;
				Zip.BufferSize = 0x10000;

				TableOfContents.Entries.ForEach( x => Zip.UpdateFile( x.Name ) );

				Log( " ... saving zip: " + Zip.Name, ConsoleColor.Green );
				Zip.Save();

				FileInfo ZipInfo = new FileInfo( Zip.Name );
				Log( "Completed saving zip with " + TotalFilesZipped + " files to " + ZipInfo.Length + " bytes (from " + TotalBytesZipped + ")", ConsoleColor.Green );
			}
		}
All Usage Examples Of Ionic.Zip.ZipFile::UpdateFile