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 721

    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.
     

    Remember: mark posts that helped you as the answer to aid future readers

    Why UpdatePanels Are Dangerous
    Why You Should Not Place Your Whole Site In An UpdatePanel
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter