Beispiel #1
0
 public bool CheckPassword(Ionic.Zip.ZipEntry entry, string password)
 {
     try
     {
         using (var s = new PasswordCheckStream())
         {
             entry.ExtractWithPassword(s, password);
         }
         return(true);
     }
     catch (Ionic.Zip.BadPasswordException)
     {
         return(false);
     }
     catch (PasswordCheckStream.GoodPasswordException)
     {
         return(true);
     }
 }
Beispiel #2
0
        public string Read(string path, string fileName, string password)
        {
            string result = "";

            try
            {
                MemoryStream ms = new MemoryStream();
                using (Ionic.Zip.ZipFile zip = Ionic.Zip.ZipFile.Read(path))
                {
                    Ionic.Zip.ZipEntry e = zip["" + fileName + ""];
                    e.ExtractWithPassword(ms, password);
                    StreamReader sr = new StreamReader(ms);
                    ms.Position = 0;
                    result      = sr.ReadToEnd();
                }
            }
            catch { }
            return(result);
        }