Problem with creating PDF on Production server

Posted on 2014-08-22
Last Modified: 2014-08-25
I have an application that creates a PDF and then stores it in a database. On my local machine everything works great, but it fails with the following error when on the production server.  Line 66 is

using (FileStream fs = File.Create(@"Eval" + DaRec + ".pdf"))

Open in new window

System.UnauthorizedAccessException: Access to the path 'C:\Windows\SysWOW64\inetsrv\Eval1200.pdf' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.IO.File.Create(String path) at GeneratePDF.Page_Load(Object sender, EventArgs e) in c:\Projects\appcreate\GeneratePDF.aspx.cs:line 66

Here is the complete code.

 using (MemoryStream myMemoryStream = new MemoryStream())

                        Document myDocument = new Document(PageSize.A1, 10f, 10f, 10f, 0f);
                        PdfWriter myPDFWriter = PdfWriter.GetInstance(myDocument, myMemoryStream);
                        WebClient wc = new WebClient();
                        string htmlText = wc.DownloadString("http://Prod40202/appcreate/GeneratePDF/CreatePDF.aspx?pid=" + DaRec);
                        Response.Write(htmlText.Replace("\r", "").Replace("\n", "").Replace("  ", ""));

                        List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), null);

                        for (int k = 0; k < htmlarraylist.Count; k++)

                        byte[] content = myMemoryStream.ToArray();
                        //    document.Close();
                        using (FileStream fs = File.Create(@"Eval" + DaRec + ".pdf"))

                            fs.Write(content, 0, (int)content.Length);
                            var p5 = ctx1.tblAttachments.SingleOrDefault(u => u.AttachmentID == RecID);
                            if (p5 != null)
                                p5.DocName = "PayEval" + DaRec + ".pdf";
                                p5.DocType = "pdf";
                                p5.DocByteSize = Convert.ToInt32(fs.Length);
                                p5.DocBinary = content;
                                p5.DateCreated = DateTime.Now;
                                Response.Redirect("OpenAttachment.aspx?pid=" + RecID);


                    catch (Exception ex)

Open in new window

Question by:NickMalloy
    1 Comment
    LVL 6

    Accepted Solution

    It is something related to Permissions on particular folder:C:\Windows\SysWOW64\inetsrv\
    righ click the folder - properties - security then give access everyone user.

    Refer this:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now