0
sharePoint 2010アプリケーションでExcelおよびPDFファイルを作成しています。私は作成されたすべてのフォルダ/ファイルを圧縮するルーチンを作成しましたが、 "タイプ 'System.Security.Permission.FileIO.Permission、mscorlib、...'のアクセス許可の要求があります。 以下は私のコードです。私はwebformプロジェクトでそれを試して、それは正常に動作します。 私はionic.zipライブラリにC#SharePoint 2010 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;
}
}
を使用すべてのヘルプは理解されるであろう。