有沒有辦法從ASP.NET的URL獲取物理文件路徑? Scenerio:我有一個在兩臺服務器上的應用程序,但現在會有很多應用程序,並且每臺服務器都將它放在不同的物理文件路徑中。現在我這樣做:ASP.NET從URL獲取物理文件路徑
//for server 1
if (Request.Url.GetLeftPart(UriPartial.Path).Contains(".com"))
{ Application["StoreFilesPath"] = "E:\\Data\\rootsite\\f1\\appsite\\Upload\\"; }
//for server 2
if (Request.Url.GetLeftPart(UriPartial.Path).Contains(".net"))
{ Application["StoreFilesPath"] = "E:\\Web\\rootsite2\\f34\\abc\\ghi\\appsite\\Upload\\"; }
但我需要做的是這樣的:
//for all servers
Application["StoreFilesPath"] = getPhysicalFilePath() +"\\Upload\\";
我該怎麼辦呢?