C#應用Directoryinfo類取得目次信息和屬性的辦法。本站提示廣大學習愛好者:(C#應用Directoryinfo類取得目次信息和屬性的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#應用Directoryinfo類取得目次信息和屬性的辦法正文
本文實例講述了C#應用Directoryinfo類取得目次信息和屬性的辦法。分享給年夜家供年夜家參考。詳細以下:
using System; using System.IO; class MainClass { static void Main(string[] args) { FileInfo file = new FileInfo("c:\\a.txt"); // Display directory information. DirectoryInfo dir = file.Directory; Console.WriteLine("Checking directory: " + dir.Name); Console.WriteLine("In directory: " + dir.Name); Console.Write("Directory exists: "); Console.WriteLine(dir.Exists.ToString()); if (dir.Exists) { Console.Write("Directory created: "); Console.WriteLine(dir.CreationTime.ToString()); Console.Write("Directory last updated: "); Console.WriteLine(dir.LastWriteTime.ToString()); Console.Write("Directory last accessed: "); Console.WriteLine(dir.LastAccessTime.ToString()); Console.Write("Directory attribute list: "); Console.WriteLine(dir.Attributes.ToString()); Console.WriteLine("Directory contains: " + dir.GetFiles().Length.ToString() + " files"); } Console.WriteLine(); } }
願望本文所述對年夜家的C#法式設計有所贊助。