使用DotNetZip库拆分压缩文件 [英] Split zip file using DotNetZip Library

查看:175
本文介绍了使用DotNetZip库拆分压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 DotNetZip图书馆来创建一个zip文件大约100MB.I'm直接保存压缩文件到Response.OutputStream

I'm using DotNetZip Library to create a zip file with about 100MB.I'm saving the zip file directly to the Response.OutputStream

Response.Clear();
    // no buffering - allows large zip files to download as they are zipped
    Response.BufferOutput = false;
    String ReadmeText= "Dynamic content for a readme file...\n" + 
                       DateTime.Now.ToString("G");
    string archiveName= String.Format("archive-{0}.zip", 
                                      DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); 
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "attachment; filename=" + archiveName);
    using (ZipFile zip = new ZipFile())
    {
        // add a file entry into the zip, using content from a string
        zip.AddFileFromString("Readme.txt", "", ReadmeText);
        // add the set of files to the zip
        zip.AddFiles(filesToInclude, "files");
        // compress and write the output to OutputStream
        zip.Save(Response.OutputStream);
    }
    Response.Close();

我需要的是在与分裂这个100MB的文件20MB左右的部分,并提供下载功能到user.how我能做到这一点?

what i need is to split this 100MB file in to with about 20MB sections and provide the download facility to the user.how can i achieve this?

推荐答案

您的问题是那种独立的ZIP方面。基本上,它似乎要做出可供下载100MB以上的大文件,并且你想这样做的部分。有些选项:

Your question is sort of independent of the ZIP aspect. Basically it seems you want to make available for download a large file of 100mb or more, and you want to do it in parts. Some options:


  • 将它保存到一个普通的文件,然后传送它的部分。客户将不得不为每个N个部分的独特下载请求,通过的 HTTP Range头。服务器都必须设置为服务器ZIP文件与适当的MIME类型等。

  • Save it to a regular file, then transmit it in parts. The client would have to make a distinct download request for each of the N parts, selecting the appropriate section of the file via the HTTP Range header. The server would have to be set up to server ZIP files with the appropriate MIME type etc.

将其保存到分(跨区)的zip文件,这意味着N个不同的文件。然后,客户端将成为一个HTTP GET每个不同的文件。服务器都必须设置为服务器的.zip,.z00,.z01,等我不知道,如果内置的操作系统工具妥善处理拆分压缩文件。

save it to a split (spanned) zip file, which implies N different files. The client would then make an HTTP GET for each of the distinct files. The server would have to be set up to server .zip, .z00, .z01, etc. I'm not sure if built-in OS tools handle split zip files appropriately.

将文件另存为一个大的斑点,并让客户端使用<一个href=\"http://stackoverflow.com/questions/397718/background-intelligent-transfer-service-in-c\">BITS或其他一些重新启动的下载工具。

save the file as one large blob, and have the client use BITS or some other restartable download facility.

这篇关于使用DotNetZip库拆分压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆