【发布时间】:2015-02-24 13:54:40
【问题描述】:
我想要实现的是,在 SharePoint 表单库中拥有一个 InfoPath 表单(.Net 4.5 c# 代码),然后按下按钮,文档库中的某些文件被打包成一个 zip 文件。 困难在于,我不能使用 3rd 方工具。
目前我的方法是这样的:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite siteCollection = new SPSite(site))
{
using (SPWeb oWeb = siteCollection.OpenWeb())
{
//Identifies the mode we will be using - the default is Create
ZipArchiveMode mode = ZipArchiveMode.Create;
using (ZipArchive zipFile = ZipFile.Open(archiveFullName, mode))
{
foreach (string file in files)
{
//Adds the file to the archive
zipFile.CreateEntryFromFile(file, Path.GetFileName(file), compression);
}
}
}
}
});
这里的问题是,ZipFile Open()-方法(也可能是“CreateEntryFromFile”-方法)没有将 URL 作为参数并引发 NotSupportedException。 有没有人知道如何解决这个问题?
提前谢谢你。 最好的祝福 绿色
【问题讨论】:
标签: c# sharepoint zip