Finding Full Qualified Path for ASP.NET App_Data Folder

Finding Full Qualified Path for ASP.NET App_Data Folder

Recently I had a requirement to add and use some xml files in my application and i pleased these xml files in ASP.NET special folder App_Data.

As we know the benefits of adding this folder in our application or for shortly I described in below couple of points.

  1. App_Data is essentially a storage point for file-based data store like .mdb, .mdf, .xls, .csv, .xml etc.., .
  2. It should not be view-able by the web and is a place for the web app to store and read data from.

And now  i need to map that xml file(s) so that i can get/set some data to it, for this as commonly need to get it though their respective path like the below:

1.XmlDocument xdoc = new XmlDocument(“~/App_Data/abc.xml”);

And now I don't want to hard code the path as shown above, for this i searched the entire BCL (Base Class Libraries) because App_Data is a special folder creating by ASP.NET so it is treated as a special folder. And finally I got the solution and below the code through which I can get fully qualified path for our App_Data folder from any place with in our application.

1.XmlDocument xdoc = new XmlDocument(System.IO.Path.Combine(<strong>AppDomain.CurrentDomain.GetData(“DataDirectory”)</strong>,”abc.xml”));


Thats it….. Happy Coding :)

Leave a Comment
  • Please add 3 and 5 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Page 1 of 1 (1 items)
Wikis - Comment List
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
  • Maheshkumar S Tiwari edited Original. Comment: Added Tags and minor edit

  • Thanks for this shortcut. I will be using this little tip!

Page 1 of 1 (2 items)