Uri.LocalPath Tulajdonság

Definíció

Lekéri egy fájlnév helyi operációsrendszer-ábrázolását.

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

Tulajdonság értéke

A fájlnév helyi operációsrendszer-ábrázolása.

Kivételek

Ez a példány relatív URI-t jelöl, és ez a tulajdonság csak abszolút URI-kra érvényes.

Példák

Az alábbi példa létrehoz egy példányt Uri , és megírja a konzol helyi elérési útját.

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

Megjegyzések

A tulajdonság által visszaadott érték nincs lefejtve. Ha az elérési út Windows fájl elérési útjaként van felismerve, a rendszer minden perjelet (/) fordított perjelek (\) vált fel.

Az URI file://computer/file.extesetében az abszolút elérési út, /file.ext a helyi elérési út pedig az \\computer\file.ext.

A következőre érvényes: