C#에서 파일 생성 시간을 얻으려면 CreationTime() 메서드를 사용하세요.
이를 위해 FileInfo 및 DateTime 클래스를 사용하십시오. 각 개체의 생성 -
FileInfo file = new FileInfo("new.txt");
DateTime dt = file.CreationTime; 전체 코드를 보자 -
예
using System.IO;
using System;
public class Program {
public static void Main() {
using (StreamWriter sw = new StreamWriter("qa.txt")) {
sw.WriteLine("Questions and Answers!");
}
FileInfo file = new FileInfo("qa.txt");
// file creation time
DateTime dt = file.CreationTime;
Console.WriteLine(dt);
}
} 출력
9/5/2018 5:20:03 AM