File Information and File Control

Learn about getting file information, including retrieving details and controlling file operations when working with files.

Getting file information

To get information about a file or directory, for example, its size or when it was last accessed, we can create an instance of the FileInfo or DirectoryInfo class. FileInfo and DirectoryInfo both inherit from FileSystemInfo, so they both have members such as LastAccessTime and Delete, as well as extra members specific to themselves, as shown in the following table:

Get hands-on with 1400+ tech skills courses.