Access to the path Server.MapPath is denied

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2012-09-21T08:50:23Z Indexed on 2012/09/21 9:38 UTC
Read the original article Hit count: 197

Filed under:
|
|

I created one pdf document

        var document = new Document();
        string path = Server.MapPath("AttachementToMail");
        PdfWriter.GetInstance(document, new FileStream(path + 
                  "/"+DateTime.Now.ToShortDateString()+".pdf", FileMode.Create));

Now I want to download this document

 Response.ContentType = "Application/pdf";
 Response.AppendHeader("Content-Disposition", "attachment; filename="+   
                                DateTime.Now.ToShortDateString() + ".pdf" + "");
 Response.TransmitFile(path);
 Response.End();

but it gave me error Access to the path '~\AttachementToMail' is denied.

read / write access for IIS_IUSRS exists

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET