Path.IsPathFullyQualified Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Retourneert een waarde die aangeeft of een bestandspad volledig is gekwalificeerd.
Overloads
| Name | Description |
|---|---|
| IsPathFullyQualified(String) |
Retourneert een waarde die aangeeft of het opgegeven bestandspad is vastgezet aan een specifiek station of UNC-pad. |
| IsPathFullyQualified(ReadOnlySpan<Char>) |
Retourneert een waarde die aangeeft of het bestandspad dat wordt vertegenwoordigd door de opgegeven tekenspanne is vastgezet aan een specifiek station of UNC-pad. |
Opmerkingen
De overbelasting van de IsPathFullyQualified methode verwerkt paden die zowel de DirectorySeparatorChar als de AltDirectorySeparatorChar tekens gebruiken. Er wordt geen validatie uitgevoerd op het pad dat wordt doorgegeven als argument. Als gevolg hiervan worden URI's geïnterpreteerd als relatieve paden en retourneren false.
Er is een verschil tussen een volledig gekwalificeerde pad (zoals aangegeven door de IsPathFullyQualified methode) en een geroot pad (zoals aangegeven door de IsPathRooted methode). Een volledig gekwalificeerd pad of absoluut pad definieert altijd een exact pad van een bepaald station of apparaat naar een doelbestand of map, en is niet afhankelijk van het huidige station of de huidige map. Op Windows systemen definieert C:/users/user1/documents/reports/2019/january/highlights.pdf een absoluut pad vanuit de hoofdmap van het C:-station naar het doelbestand, highlights.pdf. Een geroot pad geeft een beginstation of hoofdmap op, maar is afhankelijk van de huidige map (als het is geroot door een opgegeven station) of het huidige station (als het is geroot door de hoofdmap). In het volgende voorbeeld ziet u het verschil tussen volledig gekwalificeerde paden en geroote paden.
using System;
using System.IO;
class Program
{
static void Main()
{
string relative1 = "C:Documents";
ShowPathInfo(relative1);
string relative2 = "/Documents";
ShowPathInfo(relative2);
string absolute = "C:/Documents";
ShowPathInfo(absolute);
}
private static void ShowPathInfo(string path)
{
Console.WriteLine($"Path: {path}");
Console.WriteLine($" Rooted: {Path.IsPathRooted(path)}");
Console.WriteLine($" Fully qualified: {Path.IsPathFullyQualified(path)}");
Console.WriteLine($" Full path: {Path.GetFullPath(path)}");
Console.WriteLine();
}
}
// The example displays the following output when run on a Windows system:
// Path: C:Documents
// Rooted: True
// Fully qualified: False
// Full path: c:\Users\user1\Documents\projects\path\ispathrooted\Documents
//
// Path: /Documents
// Rooted: True
// Fully qualified: False
// Full path: c:\Documents
//
// Path: C:/Documents
// Rooted: True
// Fully qualified: True
// Full path: C:\Documents
Imports System.IO
Module Program
Public Sub Main()
Dim relative1 As String = "C:Documents"
ShowPathInfo(relative1)
Dim relative2 As String = "C:Documents"
ShowPathInfo(relative2)
Dim absolute As String = "C:/Documents"
ShowPathInfo(absolute)
End Sub
Private Sub ShowPathInfo(filepath As String)
Console.WriteLine($"Path: {filepath}")
Console.WriteLine($" Rooted: {Path.IsPathRooted(filepath)}")
Console.WriteLine($" Fully qualified: {Path.IsPathFullyQualified(filepath)}")
Console.WriteLine($" Full path: {Path.GetFullPath(filepath)}")
Console.WriteLine()
End Sub
End Module
' The example displays the following output when run on a Windows system:
' Path: C:Documents
' Rooted: True
' Fully qualified: False
' Full path: c:\Users\user1\Documents\projects\path\ispathrooted\Documents
'
' Path: /Documents
' Rooted: True
' Fully qualified: False
' Full path: c:\Documents
'
' Path: C:/Documents
' Rooted: True
' Fully qualified: True
' Full path: C:\Documents
IsPathFullyQualified(String)
Retourneert een waarde die aangeeft of het opgegeven bestandspad is vastgezet aan een specifiek station of UNC-pad.
public:
static bool IsPathFullyQualified(System::String ^ path);
public static bool IsPathFullyQualified(string path);
static member IsPathFullyQualified : string -> bool
Public Shared Function IsPathFullyQualified (path As String) As Boolean
Parameters
- path
- String
Een bestandspad.
Retouren
true als het pad is vastgezet aan een specifiek station of UNC-pad; false als het pad relatief is ten opzichte van het huidige station of de huidige werkmap.
Uitzonderingen
path is null.
Opmerkingen
Met deze methode worden paden verwerkt die gebruikmaken van het alternatieve adreslijstscheidingsteken. Het is een veelvoorkomende fout om ervan uit te gaan dat geroote paden (IsPathRooted(String)) niet relatief zijn. 'C:a' is bijvoorbeeld een relatief station, dat wil gezegd, het wordt omgezet in de huidige map voor C: (geroot, maar relatief). C:\a is geroot en niet relatief. De huidige map wordt dus niet gebruikt om het pad te wijzigen.
Zie ook
Van toepassing op
IsPathFullyQualified(ReadOnlySpan<Char>)
Retourneert een waarde die aangeeft of het bestandspad dat wordt vertegenwoordigd door de opgegeven tekenspanne is vastgezet aan een specifiek station of UNC-pad.
public:
static bool IsPathFullyQualified(ReadOnlySpan<char> path);
public static bool IsPathFullyQualified(ReadOnlySpan<char> path);
static member IsPathFullyQualified : ReadOnlySpan<char> -> bool
Public Shared Function IsPathFullyQualified (path As ReadOnlySpan(Of Char)) As Boolean
Parameters
- path
- ReadOnlySpan<Char>
Een bestandspad.
Retouren
true als het pad is vastgezet aan een specifiek station of UNC-pad; false als het pad relatief is ten opzichte van het huidige station of de huidige werkmap.