1

我已将文件上传到 sharepoint 文档库。尝试使用 DotNetZip 从文档库中获取这些文件,压缩它们并呈现 zip 文件。

    Response.Clear();       
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "filename=" + "MyFiles.zip");

    using (ZipFile zip = new ZipFile())

    {
    //Query the sharepoint document library and get SPFolder (folder in this case)

      foreach (SPFolder folder in userFolder.SubFolders)
      {
        foreach (SPFile file in folder.Files)

        {

                zip.AddFile(file.URL);// Is this possible?
        }    
      }       
        zip.Save(Response.OutputStream);

我们可以将文件 URL 传递给 AddFile 方法吗?如果没有,还有其他方法可以做到这一点吗?

4

2 回答 2

0

试试vZIP插件,它在我们的 SharePoint 2010 上运行良好。

于 2012-01-12T13:28:04.037 回答
0

dotnetzip addfile 方法不接受 url。它必须是相对路径或完全限定路径。请参阅文档

于 2011-11-19T16:41:11.597 回答