我想獲得的文件夾路徑在我的網站的根並將其保存到一個類的屬性,當我控制器構造函數被調用:如何從ASP.NET MVC中的控制器構造函數中找到文件夾的路徑?
public TestController:Controller{
string temp;
public TestController(){
temp = "";
}
}
我曾嘗試以下:
temp = Server.MapPath("~/TheFolder/"); // Server is null - error.
temp = Request.PhysicalApplicationPath + @"TheFolder\"; // Request is null - error.
有任何想法嗎?
Path.Combine將;-p – 2009-01-22 08:34:02
更好這個返回temp文件夾目錄,可能意味着完全錯誤的文件夾。 – 2013-12-30 11:37:34