Пример #1
0
        // ***********************************************************************


        // ***********************************************************************
        // Developer: Alrazen Estrella
        // Project: ISG12043
        // Date: September 24, 2008

        // Check Zip file if valid
        public static bool ValidateZipFile(string SourceZipFilePath)
        {
            bool success = false;

            try
            {
                Resco.IO.Zip.ZipArchive archive = Resco.IO.Zip.ZipArchive.Open(SourceZipFilePath);

                // Get all files in the zip
                foreach (string g in archive.GetAllEntries())
                {
                    success = true;
                    break;
                }
                archive.Close();
            }
            catch (Resco.IO.Zip.ArchiveCorruptedException)
            { success = false; }
            catch
            {
                success = false;
                //this.ErrorMessage = "FileConvert()|" + ex.Message.ToString();
            }
            return(success);
        }
Пример #2
0
 // Extracts all the files in the zip
 public static string ExtractAllFilesInZip(string SourceZipFilePath, string DestinationFolderPath)
 {
     try
     {
         Resco.IO.Zip.ZipArchive archive = Resco.IO.Zip.ZipArchive.Open(SourceZipFilePath);
         archive.Extract(@"\", DestinationFolderPath, null);
         archive.Close();
         GetFilesOnlyInExtractedZip(DestinationFolderPath);
         return(DestinationFolderPath);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #3
0
        // ***********************************************************************
        // Developer: Alrazen Estrella
        // Project: ISG12152
        // Date: July 21, 2008

        // Create Zip file
        public static string ZipCreate(string zipSourcePath, string zipDestination, string password)
        {
            Resco.IO.Zip.ZipArchive archive = null;

            try
            {
                archive            = new Resco.IO.Zip.ZipArchive(zipDestination, Resco.IO.Zip.ZipArchiveMode.Create, System.IO.FileShare.None);
                archive.AutoUpdate = true;
                archive.Add(zipSourcePath, @"\", password, true, null);
                return(zipDestination);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                archive.Close();
            }
        }
Пример #4
0
        // Zip all the files in a folder
        public static string ZIPAll(string zipFileName, string sourcePath, string destPath, string password, out string ZipName)
        {
            Resco.IO.Zip.ZipArchive archive = null;
            ZipName = "";
            try
            {
                string destFilePath = "";
                string fileMask     = "*.*";

                // If no given Zip filename, then get the name of the first file
                IAPL.Transport.Transactions.ServerDetails SrvrDetails = new IAPL.Transport.Transactions.ServerDetails();
                if (zipFileName.Equals(""))
                {
                    ZipName      = SrvrDetails.getFileNameOnly(System.IO.Directory.GetFiles(sourcePath, fileMask).GetValue(0).ToString());
                    ZipName      = ZipName.Substring(0, ZipName.Length - 3) + "zip";
                    destFilePath = destPath + @"\" + ZipName;
                }
                else
                {
                    destFilePath = destPath + @"\" + zipFileName;
                    ZipName      = destFilePath;
                }

                archive            = new Resco.IO.Zip.ZipArchive(destFilePath, Resco.IO.Zip.ZipArchiveMode.Create, System.IO.FileShare.None);
                archive.AutoUpdate = true;
                archive.Add(sourcePath, @"\", password, true, null);
                return(destFilePath);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                archive.Close();
            }
        }
Пример #5
0
        public static string CreateZIP(string zipPathFileName, string sourcePath, System.Collections.Hashtable fileList, string password)
        {
            Resco.IO.Zip.ZipArchive archive = null;

            try
            {
                archive            = new Resco.IO.Zip.ZipArchive(zipPathFileName, Resco.IO.Zip.ZipArchiveMode.Create, System.IO.FileShare.None);
                archive.AutoUpdate = true;

                foreach (System.Collections.DictionaryEntry file in fileList)
                {
                    // **********************************************
                    // Developer: Alrazen Estrella
                    // Project: ISG12152
                    // Date: July 21, 2008

                    // Old Code
                    //archive.Add(sourcePath + @"\" + file.Value.ToString(), @"\", password, true, null);


                    // New Code
                    archive.Add(file.Value.ToString(), zipPathFileName, password, true, null);

                    // **********************************************
                }
                return(zipPathFileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                archive.Close();
            }
        }