0

I am using this code to unzip and encrypted zip file in the server.But's it's giving me an error -- Cannot read that as a ZipFile. What is wrong here?

string extractPath = servermapPath;
ZipFile zip = new ZipFile();
if (zipPath != "")
{
    zip = ZipFile.Read(zipPath);
    Directory.CreateDirectory(extractPath);
    foreach (ZipEntry e in zip)
    {
        //e.Extract(extractPath, ExtractExistingFileAction.OverwriteSilently);      //It is for Normal Zip File.
        e.ExtractWithPassword(zipPath, "#####");
        UnzipFileExt = e.FileName;
    }
}
glennsl
  • 28,186
  • 12
  • 57
  • 75
Abhirup Ghosh
  • 135
  • 2
  • 13
  • have you tried setting the password on the archive? https://stackoverflow.com/a/27933760/1275832 – Joel Harkes Oct 12 '17 at 14:23
  • 1
    Please include the full specific error message. Also please clarify whether you could unzip the file with the same code in another place (client) – grek40 Oct 12 '17 at 14:23
  • Is the zip file itself encrypted or the file inside the zip. What encryption is used etc? have you tried decrypting the file manually? (using 7zip or other tool?) – Joel Harkes Oct 12 '17 at 14:24
  • yes.. in local this code works perfectly fine,But it's giving me the error in the server. the full error is -- Cannot read that as a ZipFile – Abhirup Ghosh Oct 12 '17 at 14:26
  • 1
    What library are you using? That does not exactly look like calls to [System.IO.Compression.ZipFile](https://msdn.microsoft.com/en-us/library/system.io.compression.zipfile(v=vs.110).aspx). – crashmstr Oct 12 '17 at 14:27
  • yes i am using System.IO.Compression library! – Abhirup Ghosh Oct 12 '17 at 14:29
  • How to you transfer the zip file to the server? – grek40 Oct 12 '17 at 14:30
  • i am downloading this from a mail using WebClient – Abhirup Ghosh Oct 12 '17 at 14:31
  • Did you already try to save the file on server and then manually unzip it. Basically, it's all about ensuring that you really have the same file on server that worked on your client. The way you transfer your file is basically more suspicious to be at fault than the compression library itself, so noone is really motivated to look into compression until you ensure that the file is really unchanged after the transfer to server completed. – grek40 Oct 16 '17 at 07:01

0 Answers0