Exemplo n.º 1
0
        /// <summary>
        /// Remove the entrie with the given filename from the ZIP archive.
        /// </summary>
        /// <param name="entryName"></param>
        /// <returns></returns>
        public bool RemoveEntry(string entryName)
        {
            int index = Entries.IndexOf(entryName);

            if (index >= 0)
            {
                try
                {
                    zipFile.RemoveEntry(entryName);
                }
                catch (Ionic.Zip.ZipException ex)
                {
                    throw ZipException.FromIonic(ex);
                }
                catch (Ionic.Zlib.ZlibException ex)
                {
                    throw ZipException.FromIonic(ex);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 static private Ionic.Zip.ZipFile GetZipFile(string fileName)
 {
     try
     {
         if (File.Exists(fileName))
         {
             return(Ionic.Zip.ZipFile.Read(fileName));
         }
         else
         {
             return(Ionic.Zip.ZipFile.Read(fileName, ReadOption));
         }
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///  Save the ZIP archive to a file.
 /// </summary>
 /// <param name="fileName">The name of the zip archive to save to. Existing files will be overwritten with great prejudice.</param>
 public void Save(string fileName)
 {
     try
     {
         zipFile.Save(fileName);
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Add a entrie in the ZIP archive from <see cref="byte"/>[]
 /// </summary>
 /// <param name="entryName"></param>
 /// <param name="stream"></param>
 /// <returns></returns>
 public void AddEntry(string entryName, Stream stream)
 {
     try
     {
         zipFile.AddEntry(ToEntryFormat(entryName), stream);
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Read and load a ZIP from file.
 /// </summary>
 /// <param name="fileName"></param>
 /// <returns></returns>
 static public ZipFile Read(string fileName)
 {
     try
     {
         return(new ZipFile(Ionic.Zip.ZipFile.Read(fileName)));
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
 static private Ionic.Zip.ZipFile GetZipFile(Stream stream)
 {
     try
     {
         return(Ionic.Zip.ZipFile.Read(stream));
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Checks a stream to see if it contains a valid ZIP archive.
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="testExtract"></param>
 /// <returns></returns>
 public static bool IsZipFile(Stream stream, bool testExtract)
 {
     try
     {
         return(Ionic.Zip.ZipFile.IsZipFile(stream, testExtract));
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Checks a file to see if it is a valid ZIP file.
 /// </summary>
 /// <param name="fileName"></param>
 /// <returns></returns>
 public static bool IsZipFile(string fileName)
 {
     try
     {
         return(Ionic.Zip.ZipFile.IsZipFile(fileName, true));
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Rewrite the directory within a ZIP file.
 /// </summary>
 /// <param name="zipFileName"></param>
 public static void FixZipDirectory(string zipFileName)
 {
     try
     {
         Ionic.Zip.ZipFile.FixZipDirectory(zipFileName);
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Checks the ZIP file to see if its directory is consistent.
 /// </summary>
 /// <param name="zipFileName"></param>
 /// <returns></returns>
 public static bool CheckZip(string zipFileName)
 {
     try
     {
         return(Ionic.Zip.ZipFile.CheckZip(zipFileName));
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Read and load a ZIP from stream.
 /// </summary>
 /// <param name="zipStream"></param>
 /// <returns></returns>
 static public ZipFile Read(Stream zipStream)
 {
     try
     {
         return(new ZipFile(Ionic.Zip.ZipFile.Read(zipStream)));
     }
     catch (Ionic.Zip.ZipException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Ionic.Zlib.ZlibException ex)
     {
         throw ZipException.FromIonic(ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }