Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting relative virtual path from physical path

Tags:

c#

path

asp.net

How can I get the relative virtual path from the physical path in asp.net? The reverse method is like below:

Server.MapPath("Virtual Path Here"); 

But what is the reverse of the upper method?

like image 725
SilverLight Avatar asked May 21 '11 11:05

SilverLight


People also ask

Which of the following MVC methods converts a virtual path to a physical path?

MapPath method is used to map the virtual path to a physical path.

What is physical path and virtual path in asp net?

Physical path - This is the actual path the file is located by IIS. Virtual path - This is the logical path to access the file which is pointed to from outside of the IIS application folder.

What is Virtualpath?

A virtual path (VP) is a collection of virtual channel connections (VC) made through an ATM network. Each VP or VC can be either permanently established or set up dynamically for the time needed to transmit information through the network.

Is a physical path but a virtual path was expected?

Generally this physical and virtual path problem occurred whenever we refer “Server. MapPath” value multiple times while using folder path in applications. To solve this e:is a physical path but a virtual path was expected we need to use Server.


1 Answers

Maybe this question is what you're looking for. There they suggest:

String RelativePath = AbsolutePath.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty); 
like image 135
Felix Martinez Avatar answered Sep 22 '22 03:09

Felix Martinez