C:\Softwares\Test\ASPnetTest\Project11\Shared\Public\Images\
如何将其转换为
Shared\Public\Images\
谢谢。
C:\Softwares\Test\ASPnetTest\Project11\Shared\Public\Images\
如何将其转换为
Shared\Public\Images\
谢谢。
如果你想将路径作为网址中使用:
您可以使用这样的事情(类在C#中是有效的太):http://geekswithblogs.net/AlsLog/archive/2006/08/03/87032.aspx
Public Function MapURL(ByVal Path As String) As String
Dim AppPath As String = _
HttpContext.Current.Server.MapPath("~")
Dim url As String = String.Format("~{0}" _
, Path.Replace(AppPath, "").Replace("\", "/"))
Return url
End Function
...要使它易:
private static string MapUrl(string path)
{
var appPath = HttpContext.Current.Server.MapPath("~");
return string.Format("~{0}", path.Replace(appPath, "").Replace("\\", "/"));
}
如果你想要的文件夹,相对于你的应用程序的基本路径:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.physicalapplicationpath.aspx
Request.PhysicalApplicationPath
会给你c:\softwares\test\aspnettest\project11
部分。然后你就可以得到相对的部分,在这里看到这个答案是:
我检索的目录列表(物理路径),并展示他们的逻辑路径。 – Nancy