FileInfo.DirectoryName 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
디렉터리의 전체 경로를 나타내는 문자열을 가져옵니다.
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 = gcnew FileInfo( fileName );
if ( !fileInfo->Exists )
{
return;
}
Console::WriteLine( " {0} has a directoryName of {1}",
fileName, fileInfo->DirectoryName );
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
*/
Dim fileName As String = "C:\TMP\log.txt"
Dim fileInfo As New FileInfo(fileName)
If Not fileInfo.Exists Then
Return
End If
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 해야 합니다.