Exemple #1
0
        public override bool TestUnZip(string filePath)
        {
            try
            {
                using (var stream = File.OpenRead(filePath))
                {
                    IReader reader = null;

                    if (IsEncryptFile(filePath))
                    {
                        if (ZipArchive.IsZipFile(filePath))
                        {
                            reader = ZipReader.Open(stream, new ReaderOptions {
                                Password = "******"
                            });
                        }
                        else if (RarArchive.IsRarFile(filePath))
                        {
                            reader = RarReader.Open(stream, new ReaderOptions {
                                Password = "******"
                            });
                        }
                    }
                    else
                    {
                        reader = ReaderFactory.Open(stream);
                    }

                    var subGuidDir =
                        new DirectoryInfo(Path.Combine(ZipBase.UnZipRootDir, Guid.NewGuid().ToString("N")));
                    subGuidDir.Create();

                    if (reader != null)
                    {
                        while (reader.MoveToNextEntry())
                        {
                            if (!reader.Entry.IsDirectory)
                            {
                                reader.WriteEntryToDirectory(subGuidDir.FullName,
                                                             new ExtractionOptions {
                                    ExtractFullPath = true, Overwrite = true
                                });
                            }
                        }

                        return(VerifyManager.Verify(subGuidDir.FullName));
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            return(false);
        }
Exemple #2
0
        public bool Verify(bool showError = false)
        {
            var result = VerifyManager.Verify(this);

            if (!result && showError)
            {
                _hasError = true;
                ShowErrorTip();
            }
            else
            {
                RemoveErrorTip();
                _hasError = false;
            }
            return(result);
        }
Exemple #3
0
 public bool Verify(bool showError = false)
 {
     return(VerifyManager.Verify(this));
 }