End of Central Directory record could not be found

后端 未结 10 1870
温柔的废话
温柔的废话 2020-11-29 10:39

I am downloading a zip file using c# program and I get the error

at System.IO.Compression.ZipArchive.ReadEndOfCentralDirectory()
   at System.IO.Compression         


        
10条回答
  •  囚心锁ツ
    2020-11-29 11:31

    In my case i absolutely KNEW that my zip was not corrupted, and I was able to figure out through trial and error that I was extracting the files to a directory with the filename and extension in the FOLDER Name.

    So Unzipping /tmp/data.zip to:

    /tmp/staging/data.zip/files_go_here

    failed with the error [End of Central Directory record could not be found]

    but extracting data.zip to this worked just fine:

    /tmp/staging/data/files_go_here

    While it might seem unusual to some folks to name a folder a filename with extension, I can't think of a single reason why you should not be able to do this, and more importantly -- the error returned is not obviously related to the cause.

    I was getting the same error with both the System.IO.Compression library and 3rd party packages such as SharpZipLib -- which is what eventually clued me in that it was a more general issue.

    I hope this helps someone and saves them some time/frustration.

提交回复
热议问题