Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I am facing the issue with my zip file ,when i try to open the file from zipped folder then it does not open ,but when i try to open file after extract the folder and then open ,it works fine ,please help me to resolve the issue,here is the function that i am using to zip with Ionic.Zip dll

C#
private void ExportToZip()
       {
           Response.Clear();
           //Response.BufferOutput = false;
           Response.ContentType = "application/zip";
           Response.AddHeader("content-disposition", "filename=\"PnLBudgetExport.zip\"");
 
           using (ZipFile zip = new ZipFile())
           {
               if (Directory.Exists(Server.MapPath(ZIP_FOLDER)))
               {
                   foreach (string file in Directory.GetFiles(Server.MapPath(ZIP_FOLDER)))
                   {
                       zip.CompressionMethod = CompressionMethod.None;
                       //int indx = file.LastIndexOf("\\");
                       //zip.AddEntry(file.Substring(indx), File.ReadAllBytes(file));
                       zip.AddFile(file, string.Empty);
                   }
               }
 
               zip.Save(Response.OutputStream);
 

           }
           DeleteTempDir();
       }
 
where ZIP_FOLDER ="~/ZipExport"



Please help me ,Thanks in advance.
Posted
Updated 20-Dec-14 9:42am
v2
Comments
BillWoodruff 20-Dec-14 9:09am    
Why not post a message on the discussion forum on DotNetZip's site:

http://dotnetzip.codeplex.com/discussions

1 solution

As far as i know, you can't access(open) file in the zipped archive. You need to extract it before.
 
Share this answer
 
Comments
vineet1304 22-Dec-14 8:10am    
Actually some files can be opened while the others are not means it gives the unpredictable behavior ,even the files that can not be opened are also not get extracted by windows ,although it can be extracted by 7-zip and can be open.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900