Chapter 8. Filesystem I/O
This chapter deals with a number of filesystem-related subjects, such as directory- or folder-based programming tasks. Some of the more advanced topics in filesystem I/O (input/output) are also touched on, such as:
Locking subsections of a file
Monitoring for certain filesystem actions
Version information in files
Various file and directory I/O techniques are used throughout the recipes to show you how to perform tasks such as creating, opening, deleting, reading, and writing with files and directories. This is fundamental knowledge that will help you understand the file I/O recipes and how to modify them for your purposes.
A number of the recipes have been updated to use the
await operators to help alleviate the latency you’d typically encounter when dealing with the filesystem or network when performing file I/O. Using
await improves your code’s overall responsiveness by allowing the I/O operations to occur but not to block the calling thread as they normally would until they’ve completed.
Unless otherwise specified, you need the following
using statements in any program that uses snippets or methods from this chapter:
using System; using System.IO;
8.1 Searching for Directories or Files Using Wildcards
You are attempting to find one or more specific files or directories that may or may not exist within the current filesystem. You might need to use wildcard characters in order ...