开发者

How to programmatically find an ASP.NET App_Data folder path

开发者 https://www.devze.com 2023-02-23 13:49 出处:网络
I need to read a file there. I tried Assembly开发者_StackOverflow中文版.ExecutingAssembly etc but that doesnt work.From asp.net it\'s simple:

I need to read a file there. I tried Assembly开发者_StackOverflow中文版.ExecutingAssembly etc but that doesnt work.


From asp.net it's simple:

Server.MapPath("~/App_Data");//anywhere


another way is:

AppDomain.CurrentDomain.GetData("DataDirectory");


String base = AppDomain.CurrentDomain.BaseDirectory; //Using above code , you will get base directory of your applications. String pathToData_App = base + "/App_Data/SqLite.db";

Above code works for me.


I needed to execute ELMAH scripts for AppData so is used this

var elmahScript = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ELMAH-1.2-db-SQLServer.sql");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号