Our current implementation on our ASP.net website doesn't support Zip64 which it needs to, so we're moving from System.IO.Compression over to DotNetZip:
https://github.com/DinoChiesa/DotNetZip

This small archive:
https://github.com/DinoChiesa/DotNetZip/files/10184907/Zip.zip

引发错误:

目前不支持超过65534个段的跨区存档.

该代码示例仅try 打开Zip文件:

using (var data = new MemoryStream(fileBytes.ToArray()))
{
    using (var archive = Ionic.Zip.ZipFile.Read(data))
    {
        ....
    }

我有点不确定这里的问题是什么,有没有简单的变通办法,或者有更好的替代库?

推荐答案

您需要了解拥有spanned个压缩文件意味着什么.这意味着一个压缩包被分割成更多的文件.

您链接的文件似乎不是这样的文件:

Archive:  Zip.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                    646370 (000000000009DCE2h)
  Actual end-cent-dir record offset:        646272 (000000000009DC80h)
  Expected end-cent-dir record offset:      646272 (000000000009DC80h)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 25 entries.
  The central directory is 3521 (0000000000000DC1h) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 642751 (000000000009CEBFh).
...

我认为问题在于如何try 读取fileBytes.ToArray()的文件.data变量应该是filename,而不是fileBytes.ToArray().

如果您查看所提供的关于如何读取压缩文件的示例,您可以从git中看到,在line 53上您会得到ZipFile zip = ZipFile.Read(args[0], options),其中args[0]是一个压缩文件名.

下面是完整的GIT示例:

/ ReadZip.cs
//
// ----------------------------------------------------------------------
// Copyright (c) 2006-2009 Microsoft Corporation.  All rights reserved.
//
// This example is released under the Microsoft Public License .
// See the license.txt file accompanying this release for
// full details.
//
// ----------------------------------------------------------------------
//
// This simple example utility simply reads a zip archive and extracts
// all elements in it, to the specified target directory.
//
// compile with:
//     csc /target:exe /r:Ionic.Zip.dll /out:ReadZip.exe ReadZip.cs
//
// Wed, 29 Mar 2006  14:36
//


using System;
using Ionic.Zip;

namespace Ionic.Zip.Examples
{
    public class ReadZip
    {
        private static void Usage()
        {
            Console.WriteLine("usage:\n  ReadZip2 <zipfile> <unpackdirectory>");
            Environment.Exit(1);
        }


        public static void Main(String[] args)
        {

            if (args.Length != 2) Usage();
            if (!System.IO.File.Exists(args[0]))
            {
                Console.WriteLine("That zip file does not exist!\n");
                Usage();
            }

            try
            {
                // Specifying Console.Out here causes diagnostic msgs to be sent to the Console
                // In a WinForms or WPF or Web app, you could specify nothing, or an alternate
                // TextWriter to capture diagnostic messages.

                var options = new ReadOptions { StatusMessageWriter = System.Console.Out };
                using (ZipFile zip = ZipFile.Read(args[0], options))
                {
                    // This call to ExtractAll() assumes:
                    //   - none of the entries are password-protected.
                    //   - want to extract all entries to current working directory
                    //   - none of the files in the zip already exist in the directory;
                    //     if they do, the method will throw.
                    zip.ExtractAll(args[1]);
                }
            }
            catch (System.Exception ex1)
            {
                System.Console.Error.WriteLine("exception: " + ex1);
            }

        }
    }
}

EDIT-上面发布的压缩文件仍然生成上述错误.我已经查过来源,找出罪魁祸首在哪里:

它认为这是一个基于this read的跨度档案.It tries to read从第二个位置开始的block的2个字节(转换为16位无符号整数).如果转换后的值为==0xFFFF,则会将该文件视为包含超过65534个段的跨转文件.可能是压缩文件中存在一些错误,导致DotNetZip失败.

Asp.net相关问答推荐

在Docker Windows中,ASP.NET核心容器在自定义端口8080上运行,但ASP.NET容器在固定端口80上运行

我们可以在一个网页中使用多个表单吗?

如何调试 Azure 500 内部服务器错误

为什么默认情况下不允许 GET 请求返回 JSON?

从 GUID 中删除破折号是个好主意吗?

IIS 6.0 通配符映射基准?

Razor 主机工厂错误

如何从 JS 访问 ViewBag

MVC5 身份验证中的......与主域之间的信任关系失败

使用 Moq 验证活动注册

在生产中使用 LocalDb 是否正常?

用于呈现

如何在 asp.net 中更改 DataBinder.Eval 的日期格式?

投票有什么问题?

在 Application_BeginRequest 中设置会话变量

在 ASP.NET 标识中添加角色

将 C# ASP.NET 数组传递给 Javascript 数组

ASP.NET Excel 导出编码问题

为什么 Controls 集合不提供所有 IEnumerable 方法?

jQuery Ajax 调用 - 成功设置变量值