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


C# SevenZipExtractor.Check方法代码示例

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


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

示例1: UnpackArchive

 static void UnpackArchive(IAbsoluteFilePath sourceFile, IAbsoluteDirectoryPath outputFolder, bool overwrite,
     bool checkFileIntegrity,
     SevenZipExtractor extracter) {
     if (checkFileIntegrity && !extracter.Check())
         throw new Exception(String.Format("Appears to be an invalid archive: {0}", sourceFile));
     outputFolder.MakeSurePathExists();
     extracter.ExtractFiles(outputFolder.ToString(), overwrite
         ? extracter.ArchiveFileNames.ToArray()
         : extracter.ArchiveFileNames.Where(x => !outputFolder.GetChildFileWithName(x).Exists)
             .ToArray());
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:11,代码来源:Compression.cs

示例2: Read

        public Stream Read(CloudFile cloudFile, OnProgress onProgress)
        {
            if (cloudFile.Format == CloudFileFormat.Original)
            {
                return provider.Read(cloudFile, onProgress);
            }
            else
            {
                Stream stream = provider.Read(cloudFile, onProgress);

                using (var decoder = new SevenZip.SevenZipExtractor(stream, password))
                {
                    if (!decoder.Check())
                    {
                        return stream;
                    }
                    else
                    {
                        Stream result = new MemoryStream();
                        if (decoder.FilesCount != 1)
                        {
                            throw new SevenZipProviderException("Cannot extract 7z package which contains no file or more than 1 file.");
                        }

                        decoder.Extracting += new EventHandler<ProgressEventArgs>(
                            (o, p) =>
                            {
                                if (onProgress != null)
                                {
                                    onProgress(cloudFile, ProcessTypes.Decompress, (p.PercentDone * stream.Length), stream.Length);
                                }
                            });

                        decoder.ExtractFile(0, result);
                        stream.Close();
                        result.Position = 0;
                        return result;
                    }
                }
            }
        }
开发者ID:xfm84,项目名称:test,代码行数:41,代码来源:SevenZipProvider.cs

示例3: DoCheck

        private void DoCheck()
        {

            string FileName = Explorer.SelectedItems[0].ParsingName;
            SevenZipExtractor extractor = new SevenZipExtractor(FileName);
            if (!extractor.Check())
                MessageBox.Show("Not Pass");
            else
                MessageBox.Show("Pass");

            extractor.Dispose();
        }
开发者ID:rad1oactive,项目名称:BetterExplorer,代码行数:12,代码来源:MainWindow.xaml.cs

示例4: Install

        //where's my async?
        public bool Install(out string err)
        {
            err = null;

            using (var wc = new WebClient())
            {
                Log.File(Localization.RequestingNvsePage, Paths.NvseLink);

                string dlLink;
                using (var resStream = wc.OpenRead(Paths.NvseLink))
                {
                    if (!Util.PatternSearch(resStream, Paths.NvseSearchPattern, out dlLink))
                    {
                        err = Localization.FailedDownloadNvse;
                        return false;
                    }
                }

                Log.File(Localization.ParsedNvseLink, dlLink.Truncate(100));

                var archiveName = Path.GetFileName(dlLink);
                var tmpPath = Path.Combine(Path.GetTempPath(), archiveName);
                wc.DownloadFile(dlLink, tmpPath);

                using (var lzExtract = new SevenZipExtractor(tmpPath))
                {
                    if (!lzExtract.Check())
                    {
                        err = string.Format(Localization.Invalid7zArchive, archiveName);
                        return false;
                    }

                    var wantedFiles = (from file in lzExtract.ArchiveFileNames
                                       let filename = Path.GetFileName(file)
                                       let ext = Path.GetExtension(filename).ToUpperInvariant()
                                       where ext == ".EXE" || ext == ".DLL"
                                       select new { file, filename }).ToArray();

                    foreach (var a in wantedFiles)
                    {
                        var savePath = Path.Combine(_fnvPath, a.filename);
                        Log.File(Localization.Extracting, a.filename);

                        using (var fsStream = File.OpenWrite(savePath))
                        {
                            try
                            {
                                lzExtract.ExtractFile(a.file, fsStream);
                            }
                            catch
                            {
                                err = Localization.FailedExtractNvse;
                                throw;
                            }
                        }
                    }
                }
            }

            Log.Dual(Localization.NvseInstallSuccessful);
            return true;
        }
开发者ID:WCapelle,项目名称:ttwinstaller,代码行数:63,代码来源:NVSE.cs

示例5: Check

        public bool Check(string iFileName, string iPassword)
        {
            FileInfo fif = new FileInfo(iFileName);
            if (!fif.Exists)
                throw new ArgumentException();

            using (SevenZipExtractor sze = new SevenZipExtractor(iFileName, iPassword))
            {
                return sze.Check();
            }

        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:12,代码来源:SevenZipZipper.cs

示例6: InstanciateZipExctractorWithPassword

        private SevenZipExtractor InstanciateZipExctractorWithPassword(string FileName, IEventListener iel)
        {
            SevenZipExtractor Sex = new SevenZipExtractor(FileName);

            bool valid = Sex.Check();

            if (valid == false)
            {
                Sex.Dispose();

                foreach (string psw in _IUnrarUserSettings.EnumerableRarPasswords)
                {                     
                      Sex = new SevenZipExtractor(FileName, psw);
                      if (Sex.Check())
                      {
                          Trace.WriteLine(string.Format("Find Password in list: {0}", psw));
                          return Sex;
                      }
                      else
                        Sex.Dispose();
                }

                string same = Path.GetFileName(FileName);
                CorruptedRarOrMissingPasswordArgs cr = new CorruptedRarOrMissingPasswordArgs(same, _AddRar);

                OnErrorUserExit(iel, cr);

                while ((!valid) && (cr.accept == true))
                {                      
                    Sex = new SevenZipExtractor(FileName, cr.Password);

                    valid = Sex.Check();
                    if (valid == false)
                    {
                        Sex.Dispose();
                        cr = new CorruptedRarOrMissingPasswordArgs(same, cr.SavePassword);

                        OnErrorUserExit(iel, cr);
                    } 
                }

                if (valid == false)
                    return null;
               
            }

            return Sex;
        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:48,代码来源:RarManagerImpl.cs

示例7: DoCheck

    private void DoCheck() {
      string FileName = _ShellListView.GetFirstSelectedItem().ParsingName;
      var extractor = new SevenZipExtractor(FileName);
      if (!extractor.Check())
        MessageBox.Show("Not Pass");
      else
        MessageBox.Show("Pass");

      extractor.Dispose();
    }
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:10,代码来源:MainWindow.xaml.cs

示例8: DoCheck

        private void DoCheck()
        {

            SevenZipExtractor extractor = new SevenZipExtractor(archive.ParsingName);
            if (!extractor.Check())
                MessageBox.Show("Not Pass");
            else
                MessageBox.Show("Pass");

            extractor.Dispose();
        }
开发者ID:rad1oactive,项目名称:BetterExplorer,代码行数:11,代码来源:ArchiveViewWindow.xaml.cs

示例9: btn_checkarchive_Click

 private void btn_checkarchive_Click(object sender, EventArgs e)
 {
     var sevenZipExtractor = new SevenZipExtractor(_pathArchive);
     var check = sevenZipExtractor.Check();
     
     var dialog = new TaskDialog();
     dialog.Text = check ? CHECK_OKE : CHECK_ERROR;
     dialog.StandardButtons = TaskDialogStandardButtons.Ok;
     
     dialog.Show();
 }
开发者ID:rad1oactive,项目名称:BetterExplorer,代码行数:11,代码来源:ArchiveDetailView.cs

示例10: compressFolder

        /// <summary>
        /// Compress All Folders in a path each folder to a individual 7zip file
        /// </summary>
        /// <param name="blShuttingDown"></param>
        private void compressFolder(ref bool blShuttingDown)
        {
            SevenZip.SevenZipCompressor compressor = null;
            SevenZip.SevenZipExtractor extractor = null;
            Stream exreader = null;
            Stream creader = null;
            Stream extestreader = null;

            string[] strfilearr = new string[1];

            try
            {
                SevenZip.SevenZipBase.SetLibraryPath(Get7ZipFolder());
                string[] Directories = Directory.GetDirectories(SourceFolder);

                //Loop through every local directory
                foreach (string strDir in Directories)
                {
                    bool blArchiveOk = false;

                    DirectoryInfo DirInfo1 = new DirectoryInfo(strDir);
                    string str7Dir = Common.WindowsPathClean(DirInfo1.FullName + ".7z");
                    string strDestination = Common.WindowsPathCombine(DestinationFolder, str7Dir, SourceFolder);

                    if (blShuttingDown)
                    {
                        _evt.WriteEntry("Compress: Shutting Down, about to Compress: " + strDir, System.Diagnostics.EventLogEntryType.Information, 5130, 50);
                        return;
                    }

                    if (!startCompressing(DirInfo1.LastWriteTime))
                    {
                        continue;
                    }

                    //Check for Original Folder
                    try
                    {
                        if (File.Exists(strDestination))
                        {
                            FileInfo file7 = new FileInfo(strDestination);
                            extestreader = new FileStream(strDestination, FileMode.Open);
                            extractor = new SevenZipExtractor(extestreader);

                            //If archive is not corrupted and KeepUncompressed is false then it is ok to delete the original
                            if (extractor.Check() && KeepOriginalFile == false)
                            {
                                //Same File compressed then ok to delete
                                if (DirInfo1.LastWriteTime == file7.LastWriteTime && Common.CalculateFolderSize(DirInfo1.FullName) == extractor.UnpackedSize && Common.GetFolderFileCount(DirInfo1.FullName) == extractor.FilesCount)
                                {
                                    Directory.Delete(DirInfo1.FullName, true);
                                }

                            }

                            continue;
                        }
                    }
                    catch (Exception)
                    {
                        _evt.WriteEntry("Compress: Failed to Delete Original File: " + DirInfo1.FullName, System.Diagnostics.EventLogEntryType.Error, 5140, 50);
                        continue;

                    }
                    finally
                    {
                        if (extestreader != null)
                        {
                            extestreader.Close();
                            extestreader.Dispose();
                            extestreader = null;
                        }
                        if (extractor != null)
                        {
                            extractor.Dispose();
                            extractor = null;
                        }
                    }

                    //Compression of Entire Folder
                    strfilearr[0] = DirInfo1.FullName;

                    try
                    {
                        compressor = new SevenZip.SevenZipCompressor();
                        compressor.CompressionMethod = SevenZip.CompressionMethod.Lzma2;
                        compressor.CompressionLevel = CompressionLvl;
                        compressor.ArchiveFormat = OutArchiveFormat.SevenZip;
                        if (!string.IsNullOrEmpty(_encryptionPassword))
                        {
                            compressor.ZipEncryptionMethod = ZipEncryptionMethod.Aes256;

                        }

                        long lFreeSpace = 0;

//.........这里部分代码省略.........
开发者ID:gvl1818,项目名称:backup-retention-service,代码行数:101,代码来源:CompressFolder.cs

示例11: compressFile

        /// <summary>
        /// Compress files individually with .7z added on the end of the filename
        /// </summary>
        /// <param name="blShuttingDown"></param>
        private void compressFile(ref bool blShuttingDown)
        {
            SevenZip.SevenZipCompressor compressor = null;
            SevenZip.SevenZipExtractor extractor = null;
            Stream exreader = null;
            Stream creader = null;
            Stream extestreader = null;
            string[] strfilearr = new string[1];

            try
            {
                AllFiles = Common.WalkDirectory(SourceFolder, ref blShuttingDown, FileNameFilter);
                SevenZip.SevenZipBase.SetLibraryPath(Get7ZipFolder());
                if (SourceFolder != DestinationFolder)
                {
                    Common.CreateDestinationFolders(SourceFolder, DestinationFolder);
                }
                if (blShuttingDown)
                {
                    throw new Exception("Shutting Down");
                }
                //Loop through every file
                foreach (System.IO.FileInfo file1 in AllFiles)
                {
                    string str7File = Common.WindowsPathClean(file1.FullName + ".7z");
                    string strDestination = Common.WindowsPathCombine(DestinationFolder, str7File, SourceFolder);

                    bool blArchiveOk = false;

                    if (blShuttingDown)
                    {
                        _evt.WriteEntry("Compress: Shutting Down, about to Compress: " + file1.FullName, System.Diagnostics.EventLogEntryType.Information, 5130, 50);
                        throw new Exception("Shutting Down");
                    }

                    //Skip over already compressed files
                    if (file1.Extension.ToLower() == ".7z" || file1.Extension.ToLower() == ".zip" || file1.Extension.ToLower() == ".rar")
                    {
                        continue;
                    }

                    if (Common.IsFileLocked(file1))
                    {
                        _evt.WriteEntry("Compress: File is locked: " + file1.FullName, System.Diagnostics.EventLogEntryType.Error, 5130, 50);
                        continue;
                    }

                    if (!startCompressing(file1.LastWriteTime))
                    {
                        continue;
                    }

                    try
                    {

                        if (File.Exists(strDestination))
                        {
                            extestreader = new FileStream(strDestination, FileMode.Open);
                            extractor = new SevenZipExtractor(extestreader);

                            //If archive is not corrupted and KeepUncompressed is false then it is ok to delete the original
                            if (extractor.Check() && KeepOriginalFile == false)
                            {

                                FileInfo file2 = new FileInfo(strDestination);
                                //Same File compressed then ok to delete
                                if (file1.LastWriteTime == file2.LastWriteTime && file1.Length == extractor.UnpackedSize && extractor.FilesCount == 1)
                                {
                                    //File.SetAttributes(file1.FullName, FileAttributes.Normal);
                                    file1.IsReadOnly = false;
                                    File.Delete(file1.FullName);
                                }
                                file2 = null;
                            }

                            continue;
                        }
                    }
                    catch (Exception)
                    {
                        _evt.WriteEntry("Compress: Failed to Delete Original File: " + file1.FullName, System.Diagnostics.EventLogEntryType.Error, 5140, 50);
                        continue;

                    }
                    finally
                    {
                        if (extestreader != null)
                        {
                            extestreader.Close();
                            extestreader.Dispose();
                            extestreader = null;
                        }
                        if (extractor != null)
                        {
                            extractor.Dispose();
                            extractor = null;
//.........这里部分代码省略.........
开发者ID:gvl1818,项目名称:backup-retention-service,代码行数:101,代码来源:CompressFolder.cs


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