Uri.MakeRelative(Uri) 메서드

정의

주의

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).

주의

Uri.MakeRelative has been deprecated. Use MakeRelativeUri(Uri uri) instead.

주의

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("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("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). http://go.microsoft.com/fwlink/?linkid=14202")]
public string MakeRelative (Uri toUri);
public string MakeRelative (Uri toUri);
[<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("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). 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입니다.

반환

String

이 URI 인스턴스와 toUri의 호스트 이름 및 체계가 같으면 이 메서드에서 상대 URI를 나타내는 String을 반환합니다. 이 상대 URI가 현재 URI 인스턴스에 추가되면 toUri 매개 변수가 생성됩니다.

호스트 이름이나 체계가 다르면 이 메서드에서 String 매개 변수를 나타내는 toUri을 반환합니다.

특성

예외

toUri이(가) null인 경우

이 인스턴스가 상대 URI를 나타내고 이 속성이 절대 URI에만 유효한 경우

예제

다음 예제에서는 2개의 Uri 인스턴스를 만듭니다. 경로 정보의 차이는 콘솔에 기록됩니다.

// Create a base Uri.
Uri^ address1 = gcnew Uri( "http://www.contoso.com/" );

// Create a new Uri from a string.
Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm?date=today" );

// Determine the relative Uri.  
Console::WriteLine( "The difference is {0}", address1->MakeRelativeUri( address2 ) );
// Create a base Uri.
Uri address1 = new Uri("http://www.contoso.com/");

// Create a new Uri from a string.
Uri address2 = new Uri("http://www.contoso.com/index.htm?date=today");

// Determine the relative Uri.
Console.WriteLine("The difference is {0}", address1.MakeRelativeUri(address2));
// Create a base Uri.
let address1 = Uri "http://www.contoso.com/"

// Create a new Uri from a string.
let address2 = Uri "http://www.contoso.com/index.htm?date=today"

// Determine the relative Uri.
printfn $"The difference is {address1.MakeRelativeUri address2}"
    ' Create a base Uri.
    Dim address1 As New Uri("http://www.contoso.com/")
    
    ' Create a new Uri from a string.
    Dim address2 As New Uri("http://www.contoso.com/index.htm?date=today")
    
    ' Determine the relative Uri.  
    Console.WriteLine("The difference is {0}", address1.MakeRelativeUri(address2))

End Sub

설명

다음 표에서는 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에 있는 경우 사용자 정보는 무시됩니다.

적용 대상