且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

转换一个URI路径在.NET中的相对文件系统路径

更新时间:2023-02-25 15:39:48

你已经尝试过使用Server.Mappath
Uri.LocalPath 属性?喜欢的东西如下:

Have you already tried Server.MapPath?
or Uri.LocalPath property? Something like following :

string uriString = "file://server/filename.ext";
// Lesson learnt - always check for a valid URI
if(Uri.IsWellFormedUriString(uriString))
{
    Uri uri = new Uri(uriString);
    Console.WriteLine(uri.LocalPath);
}