FileSystemInfo Class provides the base class for both FileInfo and DirectoryInfo objects. : File System « File Stream « C# / C Sharp






FileSystemInfo Class provides the base class for both FileInfo and DirectoryInfo objects.

 

    using System;
    using System.IO;

    class Program
    {
        static void Main(string[] args)
        {
            foreach (string entry in Directory.GetDirectories(@"C:\"))
            {
                DisplayFileSystemInfoAttributes(new DirectoryInfo(entry));
            }
        }
        static void DisplayFileSystemInfoAttributes(FileSystemInfo fsi)
        {
            string entryType = "File";
            if ((fsi.Attributes & FileAttributes.Directory) == FileAttributes.Directory )
            {
                entryType = "Directory";
            }
            Console.WriteLine("{0} entry {1} was created on {2:D}", entryType, fsi.FullName, fsi.CreationTime);
        }
    }

   
  








Related examples in the same category

1.File System Watcher DemoFile System Watcher Demo
2.FileSystem Watcher
3.FileSystemInfo.LastAccessTime Property gets or sets the time the current file or directory was last accessed.
4.FileSystemEventArgs: Changed, Created, Deleted.