I have
C:\Softwares\Test\ASPnetTest\Project11\Shared\Public\Images\
How to convert it to
Shared\Public\Images\
Thank you.
If you want the path as used in a URL:
You can use something like this (classes are valid in C# too): 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
...To make it easy:
private static string MapUrl(string path)
{
var appPath = HttpContext.Current.Server.MapPath("~");
return string.Format("~{0}", path.Replace(appPath, "").Replace("\\", "/"));
}
If you want the folder, relative to your app's base path:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.physicalapplicationpath.aspx
Request.PhysicalApplicationPath
will give you the c:\softwares\test\aspnettest\project11
part. Then you can get the relative part, see this answer here for that: