VirtualPathUtility.MakeRelative Method
Assembly: System.Web (in system.web.dll)
public static String MakeRelative ( String fromPath, String toPath )
public static function MakeRelative ( fromPath : String, toPath : String ) : String
Parameters
- fromPath
The starting virtual path to return the relative virtual path from.
- toPath
The ending virtual path to return the relative virtual path to.
Return Value
The relative virtual path from fromPath to toPath.If the fromPath and toPath parameters are not rooted; that is, they do not equal the root operator (the tilde [~]), do not start with a tilde (~), such as a tilde and a slash mark (~/) or a tilde and a double backslash (~//), or do not start with a slash mark (/), an ArgumentException exception is thrown.
Query string parameters and HTML anchors that are used in the URI are not used in determining the relative path.
If fromPath is "/directory1/file1.aspx" and toPath is "/directory2/file2.aspx", the MakeRelative method returns "../directory2/file2.aspx".
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.