Uri.IsUnc Eigenschaft

Definition

Ruft einen Wert ab, der angibt, ob es Uri sich um einen universellen Benennungskonventionspfad (UNC) handelt.

public:
 property bool IsUnc { bool get(); };
public bool IsUnc { get; }
member this.IsUnc : bool
Public ReadOnly Property IsUnc As Boolean

Eigenschaftswert

Boolean

true wenn es Uri sich um einen UNC-Pfad handelt; andernfalls false.

Ausnahmen

Diese Instanz stellt einen relativen URI dar, diese Eigenschaft ist jedoch nur für absolute URIs gültig.

Beispiele

Im folgenden Beispiel wird eine Uri Instanz erstellt und bestimmt, ob es sich um einen UNC-Pfad handelt.

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

Hinweise

Die IsUnc Eigenschaft ist true , wenn die angegebene Uri Instanz ein UNC-Pfad ist (z \\server\folder. B. //server oder file://server/folder). Diese Eigenschaft gibt true immer zurück, wenn der URI über das file://-Schema verfügt und eine Hostkomponente angibt.

Gilt für