ZipArchive.Open a zip file(the zipfile has my head flag) cann't read ZipArchiveEntry #68

Closed
opened 2026-01-29 22:06:07 +00:00 by claunia · 0 comments
Owner

Originally created by @andyhebear on GitHub (Sep 14, 2015).

        //
        //read my zip file with head
        //
         using (FileStream fs = new FileStream("mypack.data.zip", FileMode.Open, FileAccess.Read, FileShare.Read)) {
             byte[] buf = new byte[1024];
             int offset=fs.Read(buf, 0, buf.Length);
             System.Diagnostics.Debug.Assert(offset==1024);
             ZipArchive zip=ZipArchive.Open(fs, Options.LookForHeader);//cann't read
             //ZipArchive zip = ZipArchive.Open(fs, Options.None); //will throw exption
             //ZipArchive zip = ZipArchive.Open(fs, Options.KeepStreamsOpen);//cann't read
             foreach (ZipArchiveEntry zf in zip.Entries) {
                 Console.WriteLine(zf.Key);
                 //bug:the will not none in zipfile
             }
         }
    }

you can find the code in
https://github.com/RainsSoft/sharpcompress/blob/master/SharpCompress/_TestSharpCompress.cs
the "mypack.data.zip" you can open with winrar.exe,but cann't read in this code
https://github.com/RainsSoft/sharpcompress/blob/master/SharpCompress/mypack.data.zip

Originally created by @andyhebear on GitHub (Sep 14, 2015). ``` // //read my zip file with head // using (FileStream fs = new FileStream("mypack.data.zip", FileMode.Open, FileAccess.Read, FileShare.Read)) { byte[] buf = new byte[1024]; int offset=fs.Read(buf, 0, buf.Length); System.Diagnostics.Debug.Assert(offset==1024); ZipArchive zip=ZipArchive.Open(fs, Options.LookForHeader);//cann't read //ZipArchive zip = ZipArchive.Open(fs, Options.None); //will throw exption //ZipArchive zip = ZipArchive.Open(fs, Options.KeepStreamsOpen);//cann't read foreach (ZipArchiveEntry zf in zip.Entries) { Console.WriteLine(zf.Key); //bug:the will not none in zipfile } } } ``` you can find the code in https://github.com/RainsSoft/sharpcompress/blob/master/SharpCompress/_TestSharpCompress.cs the "mypack.data.zip" you can open with winrar.exe,but cann't read in this code https://github.com/RainsSoft/sharpcompress/blob/master/SharpCompress/mypack.data.zip
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#68