15.7. Files and Directories

Now let's look at the File and Directory classes of the System.IO namespace. C# provides a rich API for working with files and directories. The System.IO.File and System.IO.Directory classes are used to model files and directories. Unlike Java, C# makes a distinction between a file and a directory. The File class consists of all static methods. The static methods of the File class perform security checks on all methods. You should use the FileInfo class if you're going to reuse a file instance so that you can avoid the repetitive security checks.

The following sections briefly discuss the static methods of this class. Some of the File static methods do not throw an IOException, instead throwing a more relevant exception. ...

Get .NET for Java Developers: Migrating to C# 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.