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相关问答推荐

Visual Studio发布的网站得到错误类型JObject is not defined when page is load on server"''"

由于 Blazor Change Detection API,组件重新渲染被跳过.如何避免?

无法访问,内部,资源文件?

发布发布事件

ASP.Net:在共享/静态函数中使用 System.Web.UI.Control.ResolveUrl()

嵌套剃刀模板中的@RenderSection

是否可以在 web.config 中添加响应 http 标头?

如何在 C# 应用程序中调用 VBScript 文件?

使 Web.config 转换在本地工作

如何避免 ASP.NET MVC 中的 HttpRequestValidationException 呈现导致异常的相同视图

导航到本地 IIS Express 时,Chrome 会返回错误请求 - 请求太长

Cache.Add 绝对过期 - 是否基于 UTC?

对于 DB ID,需要一个较小的 GUID 替代方案,但对于 URL 仍然是唯一且随机的

投票有什么问题?

Request.Cookies 和 Response.Cookies 之间的区别

如何使用 jquery 设置单选按钮 Select 的值

GridView 按代码隐藏列

MVC4 - 当优化设置为 true 时Bundle 不起作用

System.Drawing.Image.FromFile() 上的内存不足异常

ModelClientValidationRule 冲突