Alex Rivera | Logout

How to get server path of physical path ?

Asked 2011-06-22T07:34:21.017
9

I want to convert this physical path "C:\bla\bla\Content\Upload\image.jpg" to server path like "/Content/Upload/image.jpg".

How can i do that ?

Edit
Report

1 Answer

2

You can do the following to get the relative path.

String filePath = @"C:\bla\bla\Content\Upload\image.jpg";

String serverPath = Request.PhysicalPath;
String relativePath = filePath.Substring(serverPath.Length, filePath.Length - serverPath.Length);
answered 2011-06-22T08:01:42.633

Your Answer