我有一个sharePoint 2010应用程序创建excel和pdf文件。我创建了一个例程来压缩所有创建的文件夹/文件,但我得到了“请求类型'System.Security.Permission.FileIO.Permission,mscorlib,...'”的错误。 以下是我的代码。我已经在webform项目上尝试了它,它工作正常。 我使用了ionic.zip库
public void GetZipOfFile(string zipname, string DirectoryToZip)
{
try
{
zipname += ".zip";
HttpResponse oResponse = HttpContext.Current.Response;
oResponse.Clear();
oResponse.Charset = "";
using (ZipFile zip = new ZipFile())
{
System.IO.Directory.GetFiles(DirectoryToZip);
zip.Comment = String.Format("This zip archive was created For Access Bank InfoPool");
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
zip.AddDirectory(DirectoryToZip);
zip.Save(oResponse.OutputStream);
zip.Dispose();
}
oResponse.ContentType = "application/octet-stream";
oResponse.AddHeader("Content-Disposition", "attachment;filename=\"" + zipname + "\"");
oResponse.End();
}
catch (Exception ex)
{
lblMessage.Visible = true;
lblMessage.Text = ex.Message;
}
}
任何帮助将不胜感激。
答案 0 :(得分:0)
解决!这是信任级别的问题。我正在编辑一个错误的配置文件(我不是最初的开发人员,我加入完成它)。
谢谢大家。