O'Reilly logo

C# 5.0 Programmer's Reference by Rod Stephens

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

Chapter 19 File System Objects

What’s in This Chapter

  • Directory and File classes
  • DriveInfo, DirectoryInfo, and FileInfo classes
  • FileSystemWatcher and Path classes
  • Managing the recycle bin

Wrox.com Downloads for This Chapter

Please note that all the code examples for this chapter are available as a part of this chapter’s code download on the book’s website at www.wrox.com/go/csharp5programmersref on the Download Code tab.

The preceding chapter described stream classes that you can use to read and write files. (It also described the File class, which isn’t a stream class but is just too useful to ignore when you use streams.) Those classes are handy but even those like StreamWriter that work at the highest levels still represent only the contents of files. They don’t give you any tools for working with the filesystem. Some of their methods can create a file, but they cannot rename or delete a file, or create or delete a directory.

This chapter describes classes that represent the filesystem. They allow you to create, rename, and delete files and directories. The final section in this chapter explains another important file-managing topic: how to use the recycle bin (wastebasket).

Filesystem Permissions

A program cannot perform a task unless the user has the appropriate permissions. Although this is true ...

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