Search⌘ K
AI Features

File Information and File Control

Explore how to use FileInfo and DirectoryInfo classes to get detailed information about files and directories. Understand how to control file access with FileMode, FileAccess, and FileShare enums. This lesson helps you efficiently manage file opening, reading, and attributes in C# applications.

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 ...