Uri.MakeRelative(Uri) 메서드

정의

주의

The method has been deprecated. Please use MakeRelativeUri(Uri uri). http://go.microsoft.com/fwlink/?linkid=14202

주의

The method has been deprecated. Please use MakeRelativeUri(Uri uri). https://go.microsoft.com/fwlink/?linkid=14202

Uri 인스턴스 간의 차이점을 확인합니다.Determines the difference between two Uri instances.

public:
 System::String ^ MakeRelative(Uri ^ toUri);
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);
[System.Obsolete("The method has been deprecated. Please use MakeRelativeUri(Uri uri). https://go.microsoft.com/fwlink/?linkid=14202")]
public string MakeRelative (Uri toUri);
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
[<System.Obsolete("The method has been deprecated. Please use MakeRelativeUri(Uri uri). https://go.microsoft.com/fwlink/?linkid=14202")>]
member this.MakeRelative : Uri -> string
Public Function MakeRelative (toUri As Uri) As String

매개 변수

toUri
Uri

현재 URI와 비교할 URI입니다.The URI to compare to the current URI.

반환

String

이 URI 인스턴스와 toUri의 호스트 이름 및 체계가 같으면 이 메서드에서 상대 URI를 나타내는 String을 반환합니다. 이 상대 URI가 현재 URI 인스턴스에 추가되면 toUri 매개 변수가 생성됩니다.If the hostname and scheme of this URI instance and toUri are the same, then this method returns a String that represents a relative URI that, when appended to the current URI instance, yields the toUri parameter.

호스트 이름이나 체계가 다르면 이 메서드에서 String 매개 변수를 나타내는 toUri을 반환합니다.If the hostname or scheme is different, then this method returns a String that represents the toUri parameter.

특성

예외

toUri이(가) null인 경우toUri is null.

이 인스턴스가 상대 URI를 나타내고 이 속성이 절대 URI에만 유효한 경우This instance represents a relative URI, and this method is valid only for absolute URIs.

예제

다음 예에서는 두 개의 Uri 인스턴스를 만듭니다.The following example creates 2 Uri instances. 경로 정보의 차이점은 콘솔에 기록 됩니다.The difference in the path information is written to the console.

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

설명

The following table shows the URI instance, toUri, and the results of calling <xref:System.Uri.MakeRelative%2A>.

현재 URI 인스턴스Current URI instance toUri 반환 값Return value
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에 있는 경우 사용자 정보는 무시 됩니다.User information, if present in the URI, is ignored.

적용 대상