Uri.LocalPath 속성

정의

파일 이름에 대한 로컬 운영 체제 표현을 가져옵니다.

public:
 property System::String ^ LocalPath { System::String ^ get(); };
public string LocalPath { get; }
member this.LocalPath : string
Public ReadOnly Property LocalPath As String

속성 값

String

파일 이름의 로컬 운영 체제 표현입니다.

예외

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

예제

다음 예제에서는 인스턴스를 Uri 만들고 콘솔에 로컬 경로를 씁니다.

Uri^ uriAddress2 = gcnew Uri( "file://server/filename.ext" );
Console::WriteLine( uriAddress2->LocalPath );
Console::WriteLine( "Uri {0} a UNC path", uriAddress2->IsUnc ? (String^)"is" : "is not" );
Console::WriteLine( "Uri {0} a local host", uriAddress2->IsLoopback ? (String^)"is" : "is not" );
Console::WriteLine( "Uri {0} a file", uriAddress2->IsFile ? (String^)"is" : "is not" );
// The example displays the following output:
//    \\server\filename.ext
//    Uri is a UNC path
//    Uri is not a local host
//    Uri is a file
Uri uriAddress2 =  new Uri("file://server/filename.ext");
Console.WriteLine(uriAddress2.LocalPath);
Console.WriteLine("Uri {0} a UNC path", uriAddress2.IsUnc ? "is" : "is not");
Console.WriteLine("Uri {0} a local host", uriAddress2.IsLoopback ? "is" : "is not");
Console.WriteLine("Uri {0} a file", uriAddress2.IsFile ? "is" : "is not");
// The example displays the following output:
//    \\server\filename.ext
//    Uri is a UNC path
//    Uri is not a local host
//    Uri is a file
let uriAddress2 = Uri "file://server/filename.ext"
printfn $"{uriAddress2.LocalPath}"
printfn $"""Uri {if uriAddress2.IsUnc then "is" else "is not"} a UNC path"""
printfn $"""Uri {if uriAddress2.IsLoopback then "is" else "is not"} a local host"""
printfn $"""Uri {if uriAddress2.IsFile then "is" else "is not"} a file"""
// The example displays the following output:
//    \\server\filename.ext
//    Uri is a UNC path
//    Uri is not a local host
//    Uri is a file
Dim uriAddress2 As New Uri("file://server/filename.ext")
Console.WriteLine(uriAddress2.LocalPath)
Console.WriteLine("Uri {0} a UNC path", IIf(uriAddress2.IsUnc, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
Console.WriteLine("Uri {0} a local host", IIf(uriAddress2.IsLoopback, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
Console.WriteLine("Uri {0} a file", IIf(uriAddress2.IsFile, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
' The example displays the following output:
'    \\server\filename.ext
'    Uri is a UNC path
'    Uri is not a local host
'    Uri is a file

설명

이 속성에서 반환된 값은 이스케이프되지 않습니다. 경로가 Windows 파일 경로로 인식되면 모든 슬래시(/)가 뒤로 슬래시(\)로 바뀝니다.

URI file://computer/file.ext의 경우 절대 경로는 /file.ext 이며 로컬 경로는 \\computer\file.ext.

적용 대상