Chapter 19 File System Objects
What’s in This Chapter
DirectoryandFileclassesDriveInfo,DirectoryInfo, andFileInfoclassesFileSystemWatcherandPathclasses- 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access