VirtualPathUtility.MakeRelative(String, String) メソッド

定義

ルート演算子 (チルダ [~]) を含む仮想パス間の相対仮想パスを返します。

public:
 static System::String ^ MakeRelative(System::String ^ fromPath, System::String ^ toPath);
public static string MakeRelative(string fromPath, string toPath);
static member MakeRelative : string * string -> string
Public Shared Function MakeRelative (fromPath As String, toPath As String) As String

パラメーター

fromPath
String

相対仮想パスを返す開始仮想パス。

toPath
String

相対仮想パスを返す終了仮想パス。

返品

fromPathからtoPathへの相対仮想パス。

例外

fromPath はルート化されていません。

-または-

toPath はルート化されていません。

注釈

fromPathパラメーターと toPath パラメーターがルート化されていない場合、つまり、ルート演算子 (チルダ [~]) と等しくない場合、チルダやスラッシュ (~/) やチルダ、二重円記号 (~//) など、チルダ (~) で始まらず、スラッシュ (/) で始まっていないか、ArgumentException例外がスローされます。

URI で使用されるクエリ文字列パラメーターと HTML アンカーは、相対パスの決定には使用されません。

fromPath"/directory1/file1.aspx"され、toPath"/directory2/file2.aspx"されている場合、MakeRelative メソッドは"../directory2/file2.aspx"を返します。

適用対象

こちらもご覧ください