在AES中将URI路径转换为绝对文件系统路径

时间:2016-01-09 01:38:31

标签: c# asp.net

在C#ASP.Net中,如何转换:

来自:http://example.com/foo/bar.html 收件人:C:\ WebServerRoot \ foo \ bar.html

1 个答案:

答案 0 :(得分:3)

考虑到“example.com”是运行ASP.NET应用程序的Web服务器,以下代码返回文件的本地(物理)路径:

var server =  HttpContext.Current.Server;
string filePath = server.MapPath("/foo/bar.html");
相关问题