Uri.MakeRelative(Uri) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
Uri.MakeRelative has been deprecated. Use MakeRelativeUri(Uri uri) instead.
警告
The method has been deprecated. Please use MakeRelativeUri(Uri uri). https://go.microsoft.com/fwlink/?linkid=14202
警告
Uri.MakeRelative has been deprecated. Use MakeRelativeUri(Uri uri).
警告
The method has been deprecated. Please use MakeRelativeUri(Uri uri). http://go.microsoft.com/fwlink/?linkid=14202
決定了兩個 Uri 實例之間的差異。
public:
System::String ^ MakeRelative(Uri ^ toUri);
[System.Obsolete("Uri.MakeRelative has been deprecated. Use MakeRelativeUri(Uri uri) instead.")]
public string MakeRelative(Uri toUri);
[System.Obsolete("The method has been deprecated. Please use MakeRelativeUri(Uri uri). https://go.microsoft.com/fwlink/?linkid=14202")]
public string MakeRelative(Uri toUri);
[System.Obsolete("Uri.MakeRelative has been deprecated. Use MakeRelativeUri(Uri uri).")]
public string MakeRelative(Uri toUri);
[System.Obsolete("The method has been deprecated. Please use MakeRelativeUri(Uri uri). http://go.microsoft.com/fwlink/?linkid=14202")]
public string MakeRelative(Uri toUri);
public string MakeRelative(Uri toUri);
[<System.Obsolete("Uri.MakeRelative has been deprecated. Use MakeRelativeUri(Uri uri) instead.")>]
member this.MakeRelative : Uri -> string
[<System.Obsolete("The method has been deprecated. Please use MakeRelativeUri(Uri uri). https://go.microsoft.com/fwlink/?linkid=14202")>]
member this.MakeRelative : Uri -> string
[<System.Obsolete("Uri.MakeRelative has been deprecated. Use MakeRelativeUri(Uri uri).")>]
member this.MakeRelative : Uri -> string
[<System.Obsolete("The method has been deprecated. Please use MakeRelativeUri(Uri uri). http://go.microsoft.com/fwlink/?linkid=14202")>]
member this.MakeRelative : Uri -> string
member this.MakeRelative : Uri -> string
Public Function MakeRelative (toUri As Uri) As String
參數
- toUri
- Uri
用來比較現有的URI。
傳回
若此 URI 實例的 toUri 主機名稱與方案相同,則此方法回傳 a String ,代表一個相對 URI,當附加於當前 URI 實例時,會產生參數 toUri 。
若主機名稱或方案不同,則此方法回傳代表String參數的 atoUri。
- 屬性
例外狀況
toUri 是 null。
此實例代表相對 URI,且此方法僅適用於絕對 URI。
備註
下表顯示 URI 實例 toUri,以及呼叫 MakeRelative的結果。
| 目前的 URI 實例 | toUri |
返回值 |
|---|---|---|
http://www.contoso.com/ |
http://www.contoso.com/test/test.htm |
test/test.htm |
http://www.contoso.com/test1/ |
http://www.contoso.com/ |
../ |
http://www.contoso.com:8000/ |
http://www.contoso.com/test/test.htm |
http://www.contoso.com/test/test.htm |
http://username@www.contoso.com/ |
http://www.contoso.com/test1/test1.txt |
test1/test1.txt |
若使用者資訊存在於 URI 中,則會被忽略。