示例#1
0
 private VFile(Stream stream, string password, bool leaveOpen)
 {
     this._disposed = false;
     this.stream    = new DecryptStream(stream, leaveOpen);
     if (string.IsNullOrEmpty(password))
     {
         this.archive = ZipArchive.Open(this.stream, new ReaderOptions()
         {
             LeaveStreamOpen = leaveOpen
         });
     }
     else
     {
         this.archive = ZipArchive.Open(this.stream, new ReaderOptions()
         {
             LeaveStreamOpen = leaveOpen, Password = password
         });
     }
     this.entrylist = new Dictionary <string, ZipArchiveEntry>(this.archive.Entries.Count, StringComparer.OrdinalIgnoreCase);
     foreach (ZipArchiveEntry entry in this.archive.Entries)
     {
         this.entrylist.Add(entry.Key, entry);
     }
 }
示例#2
0
 /// <summary>
 /// Validate if the stream contains a <see cref="VFile"/> with the given password
 /// </summary>
 /// <param name="stream">The source stream to read</param>
 /// <param name="password">The password to validate the <see cref="VFile"/></param>
 /// <returns></returns>
 public static bool IsValid(Stream stream, string password)
 {
     using (DecryptStream dec = new DecryptStream(stream, true))
         return(ZipArchive.IsZipFile(dec, password));
 }