Path.IsPathFullyQualified 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
파일 경로가 정규화되었는지 여부를 나타내는 값을 반환합니다.
오버로드
| Name | Description |
|---|---|
| IsPathFullyQualified(String) |
지정된 파일 경로가 특정 드라이브 또는 UNC 경로에 고정되어 있는지 여부를 나타내는 값을 반환합니다. |
| IsPathFullyQualified(ReadOnlySpan<Char>) |
지정된 문자 범위가 나타내는 파일 경로가 특정 드라이브 또는 UNC 경로에 고정되어 있는지 여부를 나타내는 값을 반환합니다. |
설명
메서드 핸들 경로의 IsPathFullyQualified 오버로드는 문자와 AltDirectorySeparatorChar 문자를 모두 DirectorySeparatorChar 사용합니다. 인수로 전달되는 경로에 대한 유효성 검사를 수행하지 않습니다. 결과적으로 URI는 상대 경로로 해석되고 반환 false됩니다.
정규화된 경로(메서드에서 나타낸 IsPathFullyQualified 대로)와 루트 경로(메서드에서 나타낸 IsPathRooted 대로)는 차이가 있습니다.
정규화된 경로 또는 절대 경로는 항상 특정 드라이브 또는 디바이스에서 대상 파일 또는 디렉터리로의 정확한 경로를 정의하며 현재 드라이브 또는 현재 디렉터리에 의존하지 않습니다. 예를 들어 Windows 시스템에서 C:/users/user1/documents/reports/2019/january/highlights.pdf C: 드라이브의 루트에서 대상 파일 highlights.pdf까지 절대 경로를 정의합니다.
루트 경로는 시작 드라이브 또는 루트 디렉터리를 지정하지만 현재 디렉터리(지정된 드라이브에 의해 루팅된 경우) 또는 현재 드라이브(루트 디렉터리에 의해 루팅된 경우)에 따라 달라집니다. 다음 예제에서는 정규화된 경로와 루트 경로 간의 차이점을 보여 줍니다.
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)
지정된 파일 경로가 특정 드라이브 또는 UNC 경로에 고정되어 있는지 여부를 나타내는 값을 반환합니다.
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
매개 변수
- path
- String
파일 경로입니다.
반품
true 경로가 특정 드라이브 또는 UNC 경로에 고정된 경우 false 경로가 현재 드라이브 또는 작업 디렉터리에 상대적인 경우
예외
path은 null입니다.
설명
이 메서드는 대체 디렉터리 구분 기호를 사용하는 경로를 처리합니다. 루트 경로(IsPathRooted(String))가 상대 경로가 아니라고 가정하는 것은 자주 발생하는 실수입니다. 예를 들어 "C:a"는 드라이브 상대입니다. 즉, C: (루트가 있지만 상대)의 현재 디렉터리에 대해 확인됩니다. "C:\a"는 루트이고 상대 디렉터리가 아닙니다. 즉, 현재 디렉터리가 경로를 수정하는 데 사용되지 않습니다.
추가 정보
적용 대상
IsPathFullyQualified(ReadOnlySpan<Char>)
지정된 문자 범위가 나타내는 파일 경로가 특정 드라이브 또는 UNC 경로에 고정되어 있는지 여부를 나타내는 값을 반환합니다.
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
매개 변수
- path
- ReadOnlySpan<Char>
파일 경로입니다.
반품
true 경로가 특정 드라이브 또는 UNC 경로에 고정된 경우 false 경로가 현재 드라이브 또는 작업 디렉터리에 상대적인 경우