The FileInfo and DirectoryInfo classes enable us to work
with a single file or directory. For the most part they provide equivalent
functionality to File and Directory classes, which provide static methods for
enumerating Files and Directories, but deal with a single object.
Because all Directory methods and File methods are static,
it might be more efficient to use a Directory method and File method rather
than a corresponding DirectoryInfo instance method and FileInfo instance method
if you want to perform only one action. Most Directory methods require the
path to the directory that you are manipulating and all File methods require
the path to the file that you are manipulating.
The static methods of the Directory class and File class
perform security checks on all methods. Instance methods of DirectoryInfo class
and FileInfo class should be considered instead of the corresponding static
methods of the Directory class and File class in case you are going to reuse an
object several times and avoiding the overhead of the security checks.