首页 > 解决方案 > 使用 Ionic.Zip.ZipFile 将文件添加到 zip 时出错

问题描述

我收到一个错误:System.ArgumentException:'已添加具有相同键的项目。尝试将服务器中的文件添加到 zipfile 时出现此错误。

public ActionResult DownloadStatements(string[] years, string[] months, string[] radio, string[] emails, string acctNum)
    {
        
        List<string> manypaths = (List<string>)TempData["temp"];
        
        using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
        {   
            zip.AddFiles(manypaths, @"\" + DateTime.Now.ToFileTime());
            MemoryStream output = new MemoryStream();
            zip.Save(output);
            return File(output.ToArray(), "application/zip");
        }
    }

我在 "zip.AddFiles(manypaths, @"" + DateTime.Now.ToFileTime()) 行中收到错误;每个文件都来自服务器,它们是 pdfs。路径文件如下所示:\\ftp- RTMT01\PDF_STORAGE\03_31_2017\Deposit\123_Deposit_03_31_2017_1.pdf”。这些都不是重复的,所以我不明白这个错误信息。现在用了大约2天。

标签: c#asp.net-mvc

解决方案


推荐阅读