ICSharpCode.SharpZipLib.Zip.ZipFile.Add C# (CSharp) Méthode

Add() public méthode

Add a new entry to the archive.
ZipFile has been closed. The compression method is not supported.
public Add ( string fileName, CompressionMethod compressionMethod ) : void
fileName string The name of the file to add.
compressionMethod CompressionMethod The compression method to use.
Résultat void
        public void Add(string fileName, CompressionMethod compressionMethod) {
            if (fileName==null) {
                throw new ArgumentNullException("fileName");
            }

            if (!ZipEntry.IsCompressionMethodSupported(compressionMethod)) {
                throw new ArgumentOutOfRangeException("compressionMethod");
            }

            CheckUpdating();
            contentsEdited_=true;

            ZipEntry entry=EntryFactory.MakeFileEntry(fileName);
            entry.CompressionMethod=compressionMethod;
            AddUpdate(new ZipUpdate(fileName, entry));
        }

Same methods

ZipFile::Add ( IStaticDataSource dataSource, string entryName ) : void
ZipFile::Add ( IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod ) : void
ZipFile::Add ( IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod, bool useUnicodeText ) : void
ZipFile::Add ( ZipEntry entry ) : void
ZipFile::Add ( string fileName ) : void
ZipFile::Add ( string fileName, CompressionMethod compressionMethod, bool useUnicodeText ) : void
ZipFile::Add ( string fileName, string entryName ) : void

Usage Example

Exemple #1
3
 /// <summary>
 /// Iterate thru all the filesysteminfo objects and add it to our zip file
 /// </summary>
 /// <param name="fileSystemInfosToZip">a collection of files/directores</param>
 /// <param name="z">our existing ZipFile object</param>
 private static void GetFilesToZip(FileSystemInfo[] fileSystemInfosToZip, ZipFile z)
 {
     //check whether the objects are null
     if (fileSystemInfosToZip != null && z != null)
     {
         //iterate thru all the filesystem info objects
         foreach (FileSystemInfo fi in fileSystemInfosToZip)
         {
             //check if it is a directory
             if (fi is DirectoryInfo)
             {
                 DirectoryInfo di = (DirectoryInfo)fi;
                 //add the directory
                 z.AddDirectory(di.FullName);
                 //drill thru the directory to get all
                 //the files and folders inside it.
                 GetFilesToZip(di.GetFileSystemInfos(), z);
             }
             else
             {
                 //add it
                 z.Add(fi.FullName);
             }
         }
     }
 }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipFile::Add