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

AddFiles() public method

This method adds a set of files to the ZipFile.

Use this method to add a set of files to the zip archive, in one call. For example, a list of files received from System.IO.Directory.GetFiles() can be added to a zip archive in one call.

For ZipFile properties including Encryption, , SetCompression, , ExtractExistingFile, ZipErrorAction, and CompressionLevel, their respective values at the time of this call will be applied to each ZipEntry added.

public AddFiles ( System fileNames ) : void
fileNames System /// The collection of names of the files to add. Each string should refer to a /// file in the filesystem. The name of the file may be a relative path or a /// fully-qualified path. ///
return void
        public void AddFiles(System.Collections.Generic.IEnumerable<String> fileNames)
        {
            this.AddFiles(fileNames, null);
        }

Same methods

ZipFile::AddFiles ( System fileNames, String directoryPathInArchive ) : void
ZipFile::AddFiles ( System fileNames, bool preserveDirHierarchy, String directoryPathInArchive ) : void

Usage Example

        /// <summary>
        /// This method generates the cbz file from the images in the manga book.
        /// </summary>
        /// <param name="mangaBook"></param>
        /// <param name="saveLocation">Location to save the manga book cbz file.</param>
        public void Generate(MangaBook mangaBook, string saveLocation)
        {
            OperationStatus.StartedMangaBookFileCreation(mangaBook);

            Collection<string> imageSaveLocationList = new Collection<string>();

            mangaBook.SaveLocationPath = Path.Combine(saveLocation, mangaBook.FileName());
            using (ZipFile zip = new ZipFile(mangaBook.SaveLocationPath))
            {
                SavePagesAsPhysicalFiles(mangaBook, saveLocation, imageSaveLocationList);

                // Get all pages from save location and create cbz file.

                zip.AddFiles(imageSaveLocationList);
                zip.Save();

                // Delete the temporary files.

                foreach (string path in imageSaveLocationList)
                {
                    File.Delete(path);
                }
            }

            OperationStatus.CompletedMangaBookFileCreation(mangaBook);
        }
All Usage Examples Of Ionic.Zip.ZipFile::AddFiles