Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically find an ASP.NET App_Data folder path

Tags:

I need to read a file there. I tried Assembly.ExecutingAssembly etc but that doesnt work.

like image 909
pm100 Avatar asked Apr 08 '11 03:04

pm100


People also ask

Where is the App_Data folder?

You can view the AppData folder manually by going into your Users folder, which is there in the C drive. In my case, the path is C:\Users\ADMIN . Now you should be able to see the AppData folder in your User folder. You can also access the AppData folder directly using the AppData system variable.

How to get file path in MVC c#?

string path = Request. Files["ad1file"]. FileName; FormData fd = new FormData { ad1file = Path. GetFullPath(path) };

What is the use of App_Data folder in MVC?

The App_Data folder of MVC application is used to contain the application related data files like . mdf files, LocalDB, and XML files, etc. The most important point that you need to remember is that IIS is never going to serve files from this App_Data folder.


2 Answers

From asp.net it's simple:

Server.MapPath("~/App_Data");//anywhere 
like image 53
Alberto León Avatar answered Sep 21 '22 11:09

Alberto León


another way is:

AppDomain.CurrentDomain.GetData("DataDirectory"); 
like image 23
mina morsali Avatar answered Sep 21 '22 11:09

mina morsali