For some reason ZipFile.Open started to generate "Offset to Central Directory cannot be held in an Int64". The zip file is valid and the code used to work before.
using (ZipArchive archive = ZipFile.Open(zipFileName, ZipArchiveMode.Read))
I too got the same error while running the code, and I tried to open that particular zip file from windows - it didn't open. Tried with 7-zip then also same. Then FTPed the file from the server where I did before and it started working. So I feel that something is wrong with the zip file. Try by using the original zip file from server or check is the zip file is not corrupted.
There is 1 file inside the archive and it was archived using UNIX gzip
If the archive isn't a ZipFile
(.zip
), but rather a GZip
(.gz
) you shouldn't use ZipFile
. You should use GZipStream
inside the System.IO.Compression
namespace.
If it is a .tar.gz
(sometimes .tgz
) and not a vanilla gzip (.gz
) file, you will need to get a 3rd party library to extract it, such as SharpZipLib or SharpCompress.
I had the same error while trying to read the zip content as an Object. Different micro service sends it to my service.
I figured that I used the wrong Deserialize format. I always used UF8 encoding but sometimes I got byte array so UT8 damaged the file. We fixed it by getting a header from the previous micro service that tells me the object type.
Bottom line, make sure you using the right decoder!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With