Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access the embedded xml in App_Data folder in C# project? [closed]

Tags:

c#

.net

xml

I have a xml in App_Data folder which I need to access in a page. How can I achieve this?

like image 561
Sandy Avatar asked Dec 27 '22 04:12

Sandy


2 Answers

Use Server.MapPath to get the path to your file

Server.MapPath("~/App_Data/yourxmlfile.xml")
like image 70
Ruben-J Avatar answered Jan 09 '23 18:01

Ruben-J


You could use Server.MapPath as @Ruben-J pointed out, or you could use Path.Combine with PhysicalApplicationPath property of HttpRequest.

string appdata = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, @"App_Data\yourxmlfile.xml");
like image 35
pablogq Avatar answered Jan 09 '23 19:01

pablogq