Ich habe eine sharePoint 2010-Anwendung, die Excel- und PDF-Dateien erstellt. Ich habe eine Routine erstellt, um alle erstellten Ordner/Dateien zu komprimieren, aber ich bekam "Request für die Erlaubnis des Typs 'System.Security.Permission.FileIO.Permission, mscorlib, ...'" Fehler. Unten sind meine Codes. Ich habe das auf einem Webform-Projekt versucht und es funktioniert gut. benutzte ich ionic.zip BibliothekC# SharePoint 2010 Berechtigung bei ZIP-Erstellung verweigert
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;
}
}
Jede mögliche Hilfe geschätzt wird.