O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required