The FileInfo Class

To top off the set of Info classes, there’s FileInfo. This is most likely the one you’ll be dealing with quite often if you want to pass around an object representing a file, its location, and its various attributes. The members on the type shouldn’t come as a big surprise because we all know common file-level operations.

One thing that sets it apart from the discussed Info classes so far is the capability to get to and manipulate the contents of an individual file. We ignore this aspect right now and come back to it later when discussing file I/O.

A few examples illustrating the properties of a FileInfo object are shown here:

Console.Write("Enter path: ");var path = Console.ReadLine();Console.WriteLine(); ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.