How to put file.xml in App_Data folder?

Last post 05-17-2008 3:26 AM by whatispunk. 1 replies.

Sort Posts:

  • How to put file.xml in App_Data folder?

    05-17-2008, 2:43 AM

    I am creating a website but when i put file info.xml in App_Data folder, and run website I got an error message "Could not find a part of the path 'c:\windows\system32\inetsrv\App_Data\info.xml' ". This is my code-behind in C#:

    XmlDocument doc = new XmlDocument();
    doc.Load("App_Data/info.xml");

    Is there something wrong?, so anybody help me, please?. Thank first. 

     

  • Re: How to put file.xml in App_Data folder?

    05-17-2008, 3:26 AM
    Answer
    • Loading...
    • whatispunk
    • Joined on 03-06-2007, 5:21 PM
    • Winnipeg
    • Posts 644

    Try this:

    XmlDocument doc = new XmlDocument();
    doc.Load(HttpContext.Current.Server.MapPath("~/App_Data/info.xml"));

    Or simply:

    XmlDocument doc = new XmlDocument();
    doc.Load(Server.MapPath("~/App_Data/info.xml");

    You'll need to use the first version if the method is static.
     

    Don't forget to click "Mark as Answer" if someone answers your question. Feel free to mark more than one answer, if you feel so inclined.
Page 1 of 1 (2 items)