void SevenzipWorkThread()
 {
     try
     {
         SevenZipExtractor.ArchiveFile archive = new SevenZipExtractor.ArchiveFile(workerfile);
         try
         {
             Dictionary <string, SevenZipExtractor.Entry> entmap = archive.Entries.ToDictionary(i => i.FileName);
             while (true)
             {
                 commitCommand.WaitOne();
                 if (cancel)
                 {
                     break;
                 }
                 var fname = cmdFile;
                 waitResult.Set();
                 entmap[fname].Extract(ioStream);
                 ioStream.FinishWrite();
             }
         }
         catch { }
         archive.Dispose();
     }
     catch { }
     workerfile     = null;
     sevenzipworker = null;
     waitResult.Set();
 }
Example #2
0
        public void ExtractToDirectory(string archivePath, string directoryPath)
        {
            _logger.WriteLine($"Extracting: {archivePath} to {directoryPath}");

            using (var archiveFile = new SevenZipExtractor.ArchiveFile(archivePath, _libraryPath))
            {
                archiveFile.Extract(directoryPath);
            }

            return;
        }
Example #3
0
        public void ExtractAll(string archivePath, Func <string, string> selector)
        {
            _logger.WriteLine($"Extracting: {archivePath}");

            using (var archiveFile = new SevenZipExtractor.ArchiveFile(archivePath, _libraryPath))
            {
                archiveFile.Extract(delegate(SevenZipExtractor.Entry entry) { return(selector(FixupPath(entry.FileName))); });
            }

            return;
        }
Example #4
0
        public void ExtractToDirectory(string archivePath, string directoryPath)
        {
            _logger.WriteLine($"Extracting: {archivePath} to {directoryPath}");

            using (var archiveFile = new SevenZipExtractor.ArchiveFile(archivePath))
            {
                archiveFile.Extract(delegate(SevenZipExtractor.Entry entry) { return(Path.Combine(directoryPath, entry.FileName)); });
            }

            return;
        }
        public static void ExtractAll(string pathArchive, string pathToExtract)
        {
            if (!Directory.Exists(pathToExtract))
            {
                Directory.CreateDirectory(pathToExtract);
            }

            // using (Stream stream = File.OpenRead(pathArchive))
            //{
            using (SevenZipExtractor.ArchiveFile archive = new SevenZipExtractor.ArchiveFile(pathArchive))
                archive.Extract(pathToExtract, true);



            // }
        }
        public static List <(string name, long length)> EnumerateNames(string archivename)
        {
            List <(string name, long length)> rets = new List <(string name, long length)>();

            try
            {
                using (SevenZipExtractor.ArchiveFile arcfile = new SevenZipExtractor.ArchiveFile(archivename))
                    foreach (var i in arcfile.Entries)
                    {
                        rets.Add((i.FileName, (long)i.Size));
                    }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            } //Not a valid compressed file
            return(rets);
        }
Example #7
0
        public static void ExtractAll(string pathArchive, string pathToExtract, bool deleteArchive = false)
        {
            //если конечноо пути нет, то создадим его
            if (!Directory.Exists(pathToExtract))
            {
                Directory.CreateDirectory(pathToExtract);
            }

            //распаковываем файлы в папку
            using (var archive = new SevenZipExtractor.ArchiveFile(pathArchive))
            {
                archive.Extract(pathToExtract, true);
            }

            //удаляем архив после распаковки, если надо
            if (deleteArchive)
            {
                File.Delete(pathArchive);
            }
        }