有没有办法从 ASP.NET 的 URL 获取物理文件路径?
Scenerio:我有一个应用程序在两个服务器上,但现在它会在更多服务器上,每个服务器都将它放在不同的物理文件路径中。现在我正在这样做:
//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\\";
我该怎么做?