SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

ZipEntry.Size

Last post 11-24-2007 10:57 PM by astaykov. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-22-2007 12:42 PM

    ZipEntry.Size

    I'm writing to say that the particular example:

    using System;
    using System.IO;

    using ICSharpCode.SharpZipLib.Core;
    using ICSharpCode.SharpZipLib.Zip;

    class MainClass
    {
    public static void Main(string[ args)
    {
    string[ filenames = Directory.GetFiles(args[0]);
    byte[ buffer = new byte[4096];

    using ( ZipOutputStream s = new ZipOutputStream(File.Create(args[1])) ) {

    s.SetLevel(9); // 0 - store only to 9 - means best compression

    foreach (string file in filenames) {
    ZipEntry entry = new ZipEntry(file);
    s.PutNextEntry(entry);

    using (FileStream fs = File.OpenRead(file)) {
    StreamUtils.Copy(fs, s, buffer);
    }
    }
    }
    }
     }
    Does NOT work in my case. The problem is that the entries (files) into the ZIP archive appear to be 4G each, and I try to extract I got an error.
    What Solved my problem is adding some extra lines of code:
    FileInfo fi = new FileInfo(file);
    ZipEntry entry = new ZipEntry(fi.Name);
    entry.Size = fi.Length;
    s.PutNextEntry(entry);
    Now everything works just fine.

     

    Filed under: , ,
  • 11-22-2007 7:03 PM In reply to

    Re: ZipEntry.Size

     Hi,

    A well known problem.  Its working fine either way it all depends on what you use to look at the results with.  Setting the size is the best regardless as its the slightly more efficient and provides the broadest compatability.

    Cheers, -jr-

     

  • 11-24-2007 10:57 PM In reply to

    Re: ZipEntry.Size

    Gee ;)

    The result file is being opened with WinRAR 3.51 ... if I do not set the SIZE, no success with WinRAR.

Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.