Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Zip file cannot be open with WinRAR

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #20179 |


    I’m trying to use Xceed Real-Time Zip for .Net 1.1 for delivering zip file via HTTP using ASP.NET web page. Everything works fine except I cannot open the downloaded zip file using WinRAR unzip utility. The zip file can be open using WinZip and with Windows built-in Conpressed Folder options. However, since my application is an internet web application I need the zip file to be open with any unzip utility that clients have. I was testing with the latest  version of WinRAR (3.90 beta 2).  I get the following error message from WinRAR.

    “!   C:\Temp\Test.zip: The archive is corrupt”

    Here is my code from ASP.NET code behind page.

    protected void Button1_Click(object sender, EventArgs e)



    Response.ContentType =



    “Content-Disposition”, “attachment;filename=Test.zip”);

    //Create the ZipWriter object around the stream.


    ZipWriter zipWriter1 = new Xceed.Zip.ReaderWriter.ZipWriter(Response.OutputStream);

    //The source directory.

    DirectoryInfo directoryInfo = new DirectoryInfo(@”C:\Temp\Test”);

    if (directoryInfo.Exists)


    //Get files in the current directory and all subdirectories.

    FileInfo[] files = directoryInfo.GetFiles(“*.*”,


    foreach (FileInfo file in files)


    //Create ZipItemLocalHeader for current item and write to archive.

    ZipItemLocalHeader zipItemLocalHeader1 = new ZipItemLocalHeader(file.Name, CompressionMethod.Deflated, CompressionLevel.Normal);


    byte[] buffer = new byte[1024];

    int read = 0;

    using (FileStream fs = file.OpenRead())


    //Read the current item’s data

    while ((read = fs.Read(buffer, 0, buffer.Length)) != 0)


    //Write the current item’s data to the Zip archive

    zipWriter1.WriteItemData(buffer, 0, read);





    //Close the Zip archive. Writes the archive’s central header.






    Please let me know if I’m doing something wrong here.







    Imported from legacy forums. Posted by madura (had 2371 views)

    User (Old forums)
    Post count: 23064


    Are you sure that you need a Response.Flush(); in your while ((read = fs.Read(buffer, 0, buffer.Length)) != 0) statement?  (I’m not sure but I think that just one at the end should be needed, right before the “Response.End();” .)

    If this is not causing the problem, have you check the zip file size?  If it’s not 0, have you tried opening/unzipping it with something else like WinZip? 

    I’ve just tried Winrar 3.90 with an Xceed Zip file and it is working well. 

    Imported from legacy forums. Posted by Ghislain (had 1798 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.