FileInfo.DirectoryName 속성

정의

디렉터리의 전체 경로를 나타내는 문자열을 가져옵니다.

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

속성 값

디렉터리의 전체 경로를 나타내는 문자열입니다.

예외

디렉터리 이름에 대해null 이 전달되었습니다.

정규화된 경로 이름이 시스템 정의 최대 길이를 초과합니다.

호출자에게 필요한 권한이 없는 경우

예제

다음 예제에서는 지정된 파일의 전체 경로를 검색합니다.

string   fileName = @"C:\TMP\log.txt";
FileInfo fileInfo = new FileInfo(fileName);
if (!fileInfo.Exists)
{
    return;
}

Console.WriteLine("{0} has a directoryName of {1}",
    fileName, fileInfo.DirectoryName);
/* This code produces output similar to the following,
 * though actual results may vary by machine:
 *
 * C:\TMP\log.txt has a directory name of C:\TMP
 */

설명

부모 디렉터리를 개체로 DirectoryInfo 얻으려면 속성을 사용합니다 Directory .

처음 호출되면 FileInfo 파일에 대한 정보를 호출 Refresh 하고 캐시합니다. 후속 호출에서 를 호출 Refresh 하여 정보의 최신 복사본을 가져와야 합니다.

적용 대상

추가 정보