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"); // फ़ाइल निर्माण समय DateTime dt = file.CreationTime; Console.WriteLine(dt); } }आउटपुट
9/5/2018 5:20:03 AM