更新:2007 年 11 月
返回从一个包含根操作符(代字号 [~])的虚拟路径到另一个此类虚拟路径的相对虚拟路径。
Public Shared Function MakeRelative ( _ fromPath As String, _ toPath As String _ ) As String
Dim fromPath As String Dim toPath As String Dim returnValue As String returnValue = VirtualPathUtility.MakeRelative(fromPath, _ toPath)
public static string MakeRelative( string fromPath, string toPath )
public: static String^ MakeRelative( String^ fromPath, String^ toPath )
public static String MakeRelative( String fromPath, String toPath )
public static function MakeRelative( fromPath : String, toPath : String ) : String
要返回的相对虚拟路径的起始虚拟路径。
要返回的相对虚拟路径的结束虚拟路径。
从 fromPath 到 toPath 的相对虚拟路径。
fromPath 不含有根路径。
- 或 -
toPath 不含有根路径。
如果 fromPath 和 toPath 不含有根路径(即,该路径不等于根操作符(代字号 [~]);不以代字号 (~) 开头,如一个代字号后跟一个正斜杠 (~/) 或一个代字号后跟双反斜杠 (~\\);或者不是以正斜杠 (/) 开头),则会引发 ArgumentException 异常。
URI 中使用的查询字符串参数和 HTML 定位点不用于确定相对路径。
如果 fromPath 为 "/directory1/file1.aspx" 并且 toPath 为 "/directory2/file2.aspx",则 MakeRelative 方法将返回 "../directory2/file2.aspx"。
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98