FileSystemInfo.CreationTime 속성

정의

현재 파일 또는 디렉터리를 만든 시간을 가져오거나 설정합니다.

public:
 property DateTime CreationTime { DateTime get(); void set(DateTime value); };
public DateTime CreationTime { get; set; }
member this.CreationTime : DateTime with get, set
Public Property CreationTime As DateTime

속성 값

현재 FileSystemInfo 개체를 만든 날짜와 시간입니다.

예외

Refresh()가 데이터를 초기화할 수 없는 경우

지정된 경로가 잘못되었습니다(예: 매핑되지 않은 드라이브의 경로를 지정한 경우).

현재 운영 체제가 Windows NT 이상이 아닙니다.

호출자가 잘못된 만든 시간을 설정하려고 시도합니다.

예제

다음 예제는 CreationTime 속성입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 FileSystemInfo 클래스입니다.

static void DisplayFileSystemInfoAttributes(FileSystemInfo^ fsi)
{
    //  Assume that this entry is a file.
    String^ entryType = "File";

    // Determine if entry is really a directory
    if ((fsi->Attributes & FileAttributes::Directory) == FileAttributes::Directory)
    {
        entryType = "Directory";
    }
    //  Show this entry's type, name, and creation date.
    Console::WriteLine("{0} entry {1} was created on {2:D}", entryType, fsi->FullName, fsi->CreationTime);
}
static void DisplayFileSystemInfoAttributes(FileSystemInfo fsi)
{
    //  Assume that this entry is a file.
    string entryType = "File";

    // Determine if entry is really a directory
    if ((fsi.Attributes & FileAttributes.Directory) == FileAttributes.Directory )
    {
        entryType = "Directory";
    }
    //  Show this entry's type, name, and creation date.
    Console.WriteLine("{0} entry {1} was created on {2:D}", entryType, fsi.FullName, fsi.CreationTime);
}
Sub DisplayFileSystemInfoAttributes(ByVal fsi As IO.FileSystemInfo)
    ' Assume that this entry is a file.
    Dim entryType As String = "File"

    ' Determine if this entry is really a directory.
    If (fsi.Attributes And FileAttributes.Directory) = FileAttributes.Directory Then
        entryType = "Directory"
    End If

    ' Show this entry's type, name, and creation date.
    Console.WriteLine("{0} entry {1} was created on {2:D}", _
        entryType, fsi.FullName, fsi.CreationTime)
End Sub

설명

참고

이 메서드는 운영 체제에서 값을 지속적으로 업데이트하지 않을 수 있는 네이티브 함수를 사용하기 때문에 부정확한 값을 반환할 수 있습니다.

개체의 CreationTime 현재 instance 다음 DirectoryInfo 메서드 중 하나에서 반환된 경우 속성 값 FileSystemInfo 이 미리 캐시됩니다.

최신 값을 얻으려면 메서드를 호출합니다 Refresh .

개체에 FileSystemInfo 설명된 파일이 없으면 이 속성은 1601년 1월 1일 자정(C.E.) 12:00을 반환합니다. 현지 시간으로 조정된 UTC(협정 세계시).

생성 또는 생년월일을 지원하지 않는 Unix 플랫폼에서 이 속성은 마지막 상태 변경 시간 및 마지막 수정 시간을 반환합니다. 다른 플랫폼에서는 1601년 1월 1일 자정(C.E.) 12:00을 반환합니다. 현지 시간으로 조정된 UTC(협정 세계시).

NTFS 형식의 드라이브는 파일 생성 시간과 같은 파일 메타 정보를 짧은 기간 동안 캐시할 수 있습니다. 이 프로세스를 파일 터널링이라고 합니다. 따라서 기존 파일을 덮어쓰거나 바꾸는 경우 파일 생성 시간을 명시적으로 설정해야 할 수 있습니다.

적용 대상

추가 정보