当前位置: 首页>>代码示例>>C#>>正文


C# SevenZip.SevenZipExtractor类代码示例

本文整理汇总了C#中SevenZip.SevenZipExtractor的典型用法代码示例。如果您正苦于以下问题:C# SevenZipExtractor类的具体用法?C# SevenZipExtractor怎么用?C# SevenZipExtractor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SevenZipExtractor类属于SevenZip命名空间,在下文中一共展示了SevenZipExtractor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: docxParser

        public static String docxParser(String filename)
        {
            //path to the systems temporary folder
            String tempFolderPath = Path.GetTempPath();

            //set the path of the 7z.dll (it needs to be in the debug folder)
            SevenZipExtractor.SetLibraryPath("7z.dll");

            SevenZipExtractor extractor = new SevenZipExtractor(filename);

            //create a filestream for the file we are going to extract
            FileStream f = new FileStream(tempFolderPath + "document.xml", FileMode.Create);

            //extract the document.xml
            extractor.ExtractFile("word\\document.xml", f);

            //get rid of the object because it is unmanaged
            extractor.Dispose();

            //close the filestream
            f.Close();

            //send document.xml that we extracted from the .docx to the xml parser
            String result = XMLParser.Parser.ParseXMLtoString(tempFolderPath + "document.xml");

            //delete the extracted file from the temp folder
            File.Delete(tempFolderPath + "document.xml");

            return result;
        }
开发者ID:mtotheikle,项目名称:EWU-OIT-SSN-Scanner,代码行数:30,代码来源:MSOfficeParsers.cs

示例2: Execute

            public override void Execute()
            {
                var libraryPath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), Environment.Is64BitProcess ? "7z64.dll" : "7z.dll");
                SevenZipBase.SetLibraryPath(libraryPath);

                var targetPath = new FileInfo(Path.Combine(_cmdlet.SessionState.Path.CurrentFileSystemLocation.Path, _cmdlet.TargetPath)).FullName;
                var archiveFileName = new FileInfo(Path.Combine(_cmdlet.SessionState.Path.CurrentFileSystemLocation.Path, _cmdlet.ArchiveFileName)).FullName;

                var activity = String.Format("Extracting {0} to {1}", System.IO.Path.GetFileName(archiveFileName), targetPath);
                var statusDescription = "Extracting";

                Write(String.Format("Extracting archive {0}", archiveFileName));
                WriteProgress(new ProgressRecord(0, activity, statusDescription) { PercentComplete = 0 });

                using (var extractor = new SevenZipExtractor(archiveFileName)) {
                    extractor.Extracting += (sender, args) =>
                                            WriteProgress(new ProgressRecord(0, activity, statusDescription) { PercentComplete = args.PercentDone });
                    extractor.FileExtractionStarted += (sender, args) => {
                        statusDescription = String.Format("Extracting file {0}", args.FileInfo.FileName);
                        Write(statusDescription);
                    };
                    extractor.ExtractArchive(targetPath);
                }

                WriteProgress(new ProgressRecord(0, activity, "Finished") { RecordType = ProgressRecordType.Completed });
                Write("Extraction finished");
            }
开发者ID:aolszowka,项目名称:7Zip4Powershell,代码行数:27,代码来源:Expand7Zip.cs

示例3: FileReader

        public FileReader(IFileStreamWrap stream)
        {
            if (stream == null) throw new ArgumentNullException(nameof(stream));

            //Asses file ext
            var ext = Path.GetExtension(stream.Name);
            if (ext == ".gz")
            {
                Compression = CompressionScheme.GZip;
            }

            //Assign stream
            Stream = stream;

            //If not testing assign actual stream
            if (stream.FileStreamInstance != null)
            {
                if (Compression == CompressionScheme.None)
                {
                    _reader = new StreamReaderWrap(stream.FileStreamInstance);
                }
                else if (Compression == CompressionScheme.GZip)
                {
                    // Toggle between the x86 and x64 bit dll
                   // var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
                    SevenZipExtractor.SetLibraryPath("C:\\Program Files (x86)\\7-Zip\\7z.dll");

                    _gzipStream = new SevenZipExtractor(stream.FileStreamInstance);
                    //_memoryStream = new MemoryStream();
                    //_gzipStream.ExtractFile(0, _memoryStream);
                    _gzipStream.ExtractArchive("D:\\test.txt");
                    _reader = new StreamReaderWrap(_memoryStream);              
                }
            }
        }
开发者ID:UCL-Genomics,项目名称:genomics-common,代码行数:35,代码来源:FileReader.cs

示例4: Decompress

        /// <summary>
        /// Decompresses an archive.
        /// </summary>
        /// <param name="archive">Path for the archive</param>
        /// <param name="destination">Archive content destination folder.</param>
        /// <returns>True if no errors</returns>
        public static bool Decompress(string archive, string destination)
        {
            try {
                string archive_name = Path.GetFileNameWithoutExtension(archive);
                if(main.full_path_output)
                    console.Write("Extracting " + archive + " to " + destination + " ->  0%", console.msgType.standard, false);
                else
                    console.Write("Extracting " + archive_name + " to " + destination + " ->  0%", console.msgType.standard, false);

                SevenZipExtractor zip = new SevenZipExtractor(archive);
                zip.Extracting += Zip_Extracting;
                if (!main.overwrite)
                    zip.FileExists += Zip_FileExists;
                if (main.create_dir)
                {
                    zip.ExtractArchive(destination + @"\" + archive_name);
                }
                else
                    zip.ExtractArchive(destination);
                Console.WriteLine("");
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine("");
                console.Write(e.Message +"("+archive+")", console.msgType.error);
                Log(e.ToString());
                return false;
            }
        }
开发者ID:Gabisonfire,项目名称:norar,代码行数:36,代码来源:io.cs

示例5: Update

        public void Update()
        {
            if (!IsUpdateAvailable())
            {
                throw new LauncherException("no update is available");
            }

            using (var mutex = new WurmAssistantMutex())
            {
                mutex.Enter(1000, "You must close Wurm Assistant before running update");
                var newFileZipped = WebApiClientSpellbook.GetFileFromWebApi(
                    AppContext.WebApiBasePath,
                    string.Format("{0}/{1}", AppContext.ProjectName, buildType),
                    TimeSpan.FromSeconds(15),
                    BasePath);

                using (var extractor = new SevenZipExtractor(newFileZipped.FullName))
                {
                    extractor.ExtractArchive(BasePath);
                }

                Thread.Sleep(1000);

                var cleaner = new DirCleaner(BasePath);
                cleaner.Cleanup();
            }
        }
开发者ID:webba,项目名称:WurmAssistant2,代码行数:27,代码来源:Updater.cs

示例6: ZipContainer

 public ZipContainer(SevenZipExtractor zip, ArchiveFileInfo entry, ZipContainer parent)
 {
     _name = entry.FileName;
     _entry = entry;
     Zip = zip;
     _parent = parent;
 }
开发者ID:devshorts,项目名称:FileSystemTraversal,代码行数:7,代码来源:ZipContainer.cs

示例7: Execute

 public override void Execute(DirectoryInfo targetDirectory, PortableEnvironment portableEnvironment)
 {
     // Decompress the file.
     SevenZipBase.SetLibraryPath(SevenZipLibPath);
     using (var extractor = new SevenZipExtractor(Path.Combine(targetDirectory.FullName, FileName)))
         extractor.ExtractArchive(targetDirectory.FullName);
 }
开发者ID:wernight,项目名称:papps-manager,代码行数:7,代码来源:ExtractCommand.cs

示例8: RarImporterHelper

        internal RarImporterHelper(SevenZipExtractor Sex)
        {
            string FileName = Sex.FileName;
            _DP = Path.GetFileName(FileName);

            StringAlbumParser sa = null;
            _RootDir = Sex.GetRootDir();

            if (_RootDir != null)
            {
                sa = StringAlbumParser.FromDirectoryHelper(_RootDir);
                _RootLength = _RootDir.Path.Length;
            }

            if ((sa == null) || (sa.FounSomething == false))
                sa = StringAlbumParser.FromRarZipName(FileName);

            _Album = sa.AlbumName;
            _Artist = sa.AlbumAuthor;
            _Year = sa.AlbumYear;

            _MaxLengthWithoutRoot = (from path in Sex.SafeArchiveFileNames() let npath = ConvertFileName(path) let len = (npath == null) ? 0 : npath.Length select len).Max();
            _MaxLengthFlat = (from path in Sex.ArchiveFileData let npath = Path.GetFileName(path.SafePath()) where (!path.IsDirectory) select npath.Length).Max();
            _MaxLengthBasic = (from path in Sex.SafeArchiveFileNames() select path.Length).Max();

            if (_MaxLengthFlat > _MaxLengthWithoutRoot)
                throw new Exception("Algo Error");

            if (_MaxLengthWithoutRoot > _MaxLengthBasic)
                throw new Exception("Algo Error");
        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:31,代码来源:RarImporterHelper.cs

示例9: TickReader

        public TickReader(FileInfo file)
        {
            Serializer = new PbTickSerializer();
            Codec = new QuantBox.Data.Serializer.V2.PbTickCodec();
            _stream = new MemoryStream();
            _originalLength = (int)file.Length;

            // 加载文件,支持7z解压
            var fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            {
                try
                {
                    using (var zip = new SevenZipExtractor(fileStream))
                    {
                        zip.ExtractFile(0, _stream);
                        _stream.Seek(0, SeekOrigin.Begin);
                    }
                }
                catch
                {
                    _stream = fileStream;
                    _stream.Seek(0, SeekOrigin.Begin);
                }
            }
        }
开发者ID:kandsy,项目名称:QuantBox.DataSimulator,代码行数:25,代码来源:TickReader.cs

示例10: extractToTemp

        public DirectoryInfo extractToTemp(bool force)
        {
            string modRoot;

            DirectoryInfo temp = new DirectoryInfo(TempPath);
            modRoot = Path.Combine(
                temp.FullName,
                Path.GetFileNameWithoutExtension(
                Path.GetFileNameWithoutExtension(
                FilePath)));
            DirectoryInfo modRootInfo = new DirectoryInfo(modRoot);
            if (Directory.Exists(modRoot) && !force)
            {

                m_extractedRoot = modRootInfo;
                return modRootInfo;
            }
            else
            {
                SevenZipExtractor extractor = new SevenZipExtractor(FilePath);
                modRootInfo.Create();
                extractor.ExtractArchive(modRoot);
                m_extractedRoot = modRootInfo;
                return modRootInfo;
            }
        }
开发者ID:barcharcraz,项目名称:SMMM,代码行数:26,代码来源:CompressedFile.cs

示例11: ExtractBytes

        public static byte[] ExtractBytes(byte[] data)
        {
            Inits.EnsureBinaries();

            using (var inStream = new MemoryStream(data))
            {
                using (var outStream = new MemoryStream())
                {
                    try
                    {
                        using (var extract = new SevenZipExtractor(inStream))
                        {
                            extract.ExtractFile(0, outStream);
                            return outStream.ToArray();
                        }
                    }
                    catch
                    {
                        try
                        {
                            return SevenZipExtractor.ExtractBytes(inStream.ToArray());
                        }
                        catch { return null; }
                    }
                }
            }
        }
开发者ID:IsaacSanch,项目名称:KoruptLib,代码行数:27,代码来源:Generic.cs

示例12: Extract

 public static void Extract(string file, string to)
 {
     using (var extractor = new SevenZipExtractor(file))
     {
         extractor.ExtractArchive(to);
     }
 }
开发者ID:shirshmx,项目名称:Monocle-Record-Rssdk,代码行数:7,代码来源:Lzma.cs

示例13: Decompress

        private void Decompress(string[] args)
        {
            //If no file name is specified, write usage text.

            if (args.Length == 0)
            {
                Console.WriteLine("error");
            }
            else
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if (File.Exists(args[i]))
                    {
                        SevenZipExtractor.SetLibraryPath(@"C:\Users\thlacroi\AppData\Local\Apps\COMOS\COMOS Walkinside 6.2 (64 bit)\7z.dll");
                        using (var tmp = new SevenZipExtractor(args[i]))
                        {
                            for (int n = 0; n < tmp.ArchiveFileData.Count; n++)
                            {
                                if (tmp.ArchiveFileData[n].FileName.Contains(".xml"))
                                {
                                    tmp.ExtractFiles(Path.Combine(Resource.DirectoryTmp, i.ToString()), tmp.ArchiveFileData[n].Index);
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:CapG,项目名称:POC_WIPlugin_DatasExporter,代码行数:29,代码来源:IVRExportScenario.cs

示例14: extract

 public static void extract(string fileName, string directory)
 {
     SevenZipExtractor.SetLibraryPath("7z.dll");
     SevenZipExtractor extractor = new SevenZipExtractor(fileName);
     extractor.Extracting += new EventHandler<ProgressEventArgs>(extr_Extracting);
     extractor.FileExtractionStarted += new EventHandler<FileInfoEventArgs>(extr_FileExtractionStarted);
     extractor.ExtractionFinished += new EventHandler<EventArgs>(extr_ExtractionFinished);
     extractor.ExtractArchive(directory);
 }
开发者ID:Tungul,项目名称:SlickUpdater,代码行数:9,代码来源:Unzippy.cs

示例15: CreateByUnzippingFile

 internal DirectoryHandle CreateByUnzippingFile(string zipFilePath)
 {
     var dir = CreateTempDirectory();
     zipFilePath = AbsolutizePath(zipFilePath);
     var extractor =
         new SevenZipExtractor(File.OpenRead(zipFilePath));
     extractor.ExtractArchive(dir.FullName);
     return new DirectoryHandle(this, dir);
 }
开发者ID:imtheman,项目名称:WurmApi,代码行数:9,代码来源:TempDirectoriesManager.cs


注:本文中的SevenZip.SevenZipExtractor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。