Accessing file from App_Data folder

Posted by Niladri.biswas under ASP.NET category on | Points: 40 | Views : 2380
Many time it happens that we need to access the file that we store in the App_Data folder. Here are two ways

a) Solution 1

var filePath = HttpContext.Current.Server.MapPath(string.Concat("~/App_Data/","Thefilename"));

b) Solution 2

string appdatafolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "App_Data");
var filePath = string.Concat(appdatafolder,"\\","Thefilename")

Hope this helps

Comments or Responses

Login to post response