Hi All,
I have been working on our Zipping library. My primary target is to zip the files in an Zip file with AES encryption Applied on it. and my secondary target is to append more files to the already created zip. At this part, I can able to append the file but while extracting i get an error that the Unknown Method in / No Files to extract
The Following is the code i have used for AES encryption and adding the file.
if (!File.Exists(strFilePath + "\\" + strZipFile + ".zip"))
{
using (ZipOutputStream zip = new ZipOutputStream(File.Open(strFilePath + strZipFile + ".zip", FileMode.OpenOrCreate)))
{
zip.UseZip64 = UseZip64.Off;
zip.SetLevel(9);
if (strPassReq.ToString().Trim().Equals("Y"))
{
zip.Password = strPasswd.Trim();
}
ICSharpCode.SharpZipLib.Zip.ZipEntry entry = new ICSharpCode.SharpZipLib.Zip.ZipEntry(strFileName.Substring(strFileName.LastIndexOf("\\") + 1));
if (strPassReq.ToString().Trim().Equals("Y"))
entry.AESKeySize = 256;
entry.DateTime = DateTime.Now;
zip.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(strFilePath + strFileName))
{
byte[ buffer = new byte[4096];
int bytes = 1;
while (bytes > 0)
{
bytes = fs.Read(buffer, 0, buffer.Length);
zip.Write(buffer, 0, bytes);
}
}
zip.Finish();
zip.Close();
//File.Delete(strFilePath + strFileName);
ZFname = strZipFile + ".zip";
}
}
else
{
ZipFile zfile = new ZipFile(strFilePath + "\\" + strZipFile + ".zip");
zfile.UseZip64 = UseZip64.Off;
if (strPassReq.ToString().Trim().Equals("Y"))
{
zfile.Password = strPasswd;
}
zfile.BeginUpdate();
zfile.Add(strFilePath + strFileName, strFileName);
if (strPassReq.ToString().Trim().Equals("Y"))
{
zfile.Password = strPasswd.Trim();
}
zfile.CommitUpdate();
zfile.Close();
//File.Delete(strFilePath + "\\" + strFileName);
ZFname = strZipFile + ".zip";
}
There are no errors in the above code.