Example #1
0
        public CdwAnalyzer(Stream fileStream)
        {
            IsCompleted = false;
            var z = new ZFile();

            if (!z.IsZip(fileStream))
            {
                return;
            }
            z.ExtractFileToMemoryStream(fileStream, "MetaInfo");
            LoadFromMemoryStream(z.OutputMemStream);
            if (!Opened)
            {
                return;
            }
            try
            {
                RunParseCdw();
            }
            catch
            {
                Opened      = false;
                IsCompleted = false;
            }
        }
Example #2
0
        /// <summary>
        /// Метод, работающий в отдельном потоке при запуске механизма распаковки.
        /// </summary>
        private void AR_Wrk_DoWork(object sender, DoWorkEventArgs e)
        {
            // Начинаем процесс распаковки с выводом индикатора прогресса...
            if (File.Exists(ArchName))
            {
                using (ZipFile Zip = ZipFile.Read(ArchName))
                {
                    // Формируем счётчики...
                    int TotalFiles = Zip.Count;
                    int i = 1, j = 0;

                    // Начинаем распаковку архива...
                    foreach (ZipEntry ZFile in Zip)
                    {
                        try { ZFile.Extract(DestDir, ExtractExistingFileAction.OverwriteSilently); j = (int)Math.Round(((double)i / (double)TotalFiles * (double)100.00), 0); i++; if ((j >= 0) && (j <= 100))
                              {
                                  AR_Wrk.ReportProgress(j);
                              }
                        } catch (Exception Ex) { CoreLib.WriteStringToLog(Ex.Message); }
                    }
                }
            }
            else
            {
                throw new FileNotFoundException("Archive not found.", ArchName);
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            ZFile zfile = new ZFile();

            zfile.Copy();
            zfile.Calculate20();
            zfile.Calculate08();
            //Console.ReadLine();
        }
Example #4
0
 private void LoadDirectory()
 {
     m_dirIndex  = new Dictionary <string, ZDirItem>();
     m_directory = new ZFolder();
     foreach (var entry in Zip.Entries)
     {
         var npath = VirtualFileExtension.NormalizePath(entry.FileName);
         var items = npath.Split('/');
         var fld   = FindZFolder(items, m_directory, 0, entry.IsDirectory ? items.Length : items.Length - 1);
         if (!entry.IsDirectory)
         {
             var zfile = new ZFile {
                 Path = npath
             };
             fld.Files.Add(zfile);
             m_dirIndex[npath] = zfile;
         }
     }
 }
Example #5
0
        /// <summary>
        /// Extracts archive to specified destination directory.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Additional arguments.</param>
        private void AR_Wrk_DoWork(object sender, DoWorkEventArgs e)
        {
            // Parsing arguments list...
            List <String> Arguments = e.Argument as List <String>;

            // Checking if archive file exists...
            if (File.Exists(Arguments[0]))
            {
                // Opening archive...
                using (ZipFile Zip = ZipFile.Read(Arguments[0]))
                {
                    // Creating some counters...
                    int TotalFiles = Zip.Count;
                    int CurrentFile = 1, CurrentPercent = 0;

                    // Unpacking archive contents...
                    foreach (ZipEntry ZFile in Zip)
                    {
                        try
                        {
                            // Extracting file, then counting and reporting progress...
                            ZFile.Extract(Arguments[1], ExtractExistingFileAction.OverwriteSilently);
                            CurrentPercent = (int)Math.Round(CurrentFile / (double)TotalFiles * 100.00d, 0); CurrentFile++;
                            if ((CurrentPercent >= 0) && (CurrentPercent <= 100))
                            {
                                AR_Wrk.ReportProgress(CurrentPercent);
                            }
                        }
                        catch (Exception Ex)
                        {
                            Logger.Warn(Ex);
                        }
                    }
                }
            }
            else
            {
                throw new FileNotFoundException(AppStrings.AR_BkgWrkExText, Arguments[0]);
            }
        }