O'Reilly logo

C# Primer Plus by Klaus Michelsen

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

When you create a new FileInfo object, you must associate this object with a file by passing a string representation of a filename to the FileInfo constructor. This filename can either represent an already existing file, or a non-existing file that you want to create. We will look at how you can create a new file with FileInfo later.

Suppose that C:\MyTestFiles\MyFairytale.txt is an already existing file. The following line (taken from line 10 in Listing 22.1)

FileInfo existingFile = new FileInfo(@"C:\MyTestFiles\MyFairytale.txt");

creates a FileInfo object called existingFile that represents the file MyFairytale.txt located in the C:\MyTestFiles directory.

Why Use @ in Front of Filenames?

Why does the previous line of source ...

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