Uri.LocalPath プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ローカル オペレーティング システムでのファイル名表現を取得します。
public:
property System::String ^ LocalPath { System::String ^ get(); };
C#
public string LocalPath { get; }
member this.LocalPath : string
Public ReadOnly Property LocalPath As 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
C#
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
.
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |