How to access embedded xml in App_Data folder in a C # project?

I have xml in the App_Data folder that I need to get on the page. How can I achieve this?

+4
source share
2 answers

Use Server.MapPath to get the path to your file

Server.MapPath("~/App_Data/yourxmlfile.xml") 
+9
source

You can use Server.MapPath as indicated by @ Ruben-J, or you can use Path.Combine with the PhysicalApplicationPath property of HttpRequest.

 string appdata = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, @"App_Data\yourxmlfile.xml"); 
+1
source

All Articles