zip file password protection using C# and SharpZipLib

want to check whether the given input .zip file is password protected

Page 1 of 1

0 Replies - 4849 Views - Last Post: 19 February 2009 - 12:50 AM Rate Topic: -----

#1 muthurani  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-February 09

zip file password protection using C# and SharpZipLib

Posted 19 February 2009 - 12:50 AM

Hi all,
I want to check whether the given input .zip file is password protected or not using c#.net.
i used the below mentioned code. But the problem in the below line
"oZip.CreateEmptyDirectories = false".

while passing the first protected zip file..i am getting the error message like "No password available for encrypted stream". But for second protected zip file am getting the error message like Object reference not set to an instance of an object. i dont know why..


i am in the situation to resolve this one..so need this help..
try

{

string targetDirectory = @"D:\";

oZip.CreateEmptyDirectories = false;

oZip.ExtractZip(FileName, targetDirectory, "");

if (oZip != null)

{

oZip = null;

}


}

catch (Exception exZip)

{

string errZip = exZip.Message.ToString();

if (errZip == "No password available for encrypted stream")

{

if (oZip != null)

{

oZip = null;

}

l_bintegator = true;

}


}



Thanks in advance,
Muthurani.M

Is This A Good Question/Topic? 0
  • +

Page 1 of 1