Working with Files and Streams in C# 9
C# has so many different ways to work with the file system and read and write data. It can be difficult to know what the best approach is and where to start. This course will teach you how to manipulates files, directories, paths, and streams in C#.
What you'll learn
C# gives you many different ways to interact with the file system and read and write different types of data. It can be difficult however to know what the best approach is and where to find the classes that your file IO code needs. In this course, Working with Files and Streams in C# 9, you’ll gain the ability to manipulate files, directories, paths, and streams. First, you’ll explore how to manipulate files, directories, and paths. Next, you’ll discover how to monitor the file system and respond to changes such as a new file being written. Finally, you’ll learn how to both read and write text, binary, and CSV data by either reading the entire file into memory or by processing data in smaller chunks using streams. When you’re finished with this course, you’ll have the skills and knowledge of files and streams needed to read, process, and write data in C#.
Table of contents
- Version Check 0m
- Introduction 3m
- Creating a New Console App 6m
- Checking if a File Exists 4m
- Getting the Parent Directory of a Path 3m
- Checking if a Directory Exists and Creating New Directories 4m
- Copying a File 3m
- Moving a File 4m
- Getting the File Extension from a File Name 6m
- Deleting a Directory 2m
- Enumerating All the Files in a Directory 3m
- Summary 1m
- Introduction 2m
- Introducing the FileSystemWatcher Class 2m
- The InternalBufferSize Property 2m
- Configuring Notification Filters 1m
- Additional Properties 1m
- Refactoring to Use a FileSystemWatcher 6m
- Observing the FileSystemWatcher Events 6m
- Automatically Processing Created Files 2m
- Automatically Processing Changed Files 3m
- Ignoring Duplicate FileSystemWatcher Events with a ConcurrentDictionary 6m
- Ignoring Duplicate FileSystemWatcher Events with a MemoryCache 6m
- Adding Existing File Processing 1m
- FileSystemWatcher Testing Considerations 2m
- Summary 1m
- Introduction 2m
- An Introduction to Streams 3m
- The Benefits of Streams 1m
- .NET Class Hierarchy Overview 4m
- Using Streams to Read and Write Text Content 6m
- Simplifying StreamReader and StreamWriter Creation 2m
- Selectively Processing Part of Stream 1m
- Using Streams to Read and Write Binary Data 5m
- Using BinaryReader and BinaryWriter 4m
- Specifying Text Encodings 1m
- Using Streams to Append Data 1m
- Random FileStream Access 3m
- MemoryStream Overview 1m
- Asynchronous Streams Overview 3m
- Summary 2m
- Introduction 1m
- An Overview of the CsvHelper Library 1m
- Reading CSV Data Dynamically 6m
- Configuring CSV Comment Reading 2m
- Configuring Trimming of Whitespace 1m
- Configuring CSV Blank Line Handling 1m
- Configuring CSV File Headers 3m
- Configuring a Custom Delimiter 2m
- Reading CSV Data in a Strongly Typed Way 2m
- Configuring Custom Class Mapping 5m
- Creating Custom Type Converters 3m
- Configuring Header Validation and Missing Field Actions 3m
- Writing CSV Files 4m
- Summary 2m
- Introduction 1m
- The Problems with Testing File Access Code 2m
- An Overview of System.IO.Abstractions 2m
- Refactoring for Testability 5m
- Adding a TextFileProcessor Test 7m
- Adding a BinaryFileProcessor Test 3m
- Adding a CsvFileProcessor Test 2m
- Asserting Mock File Output with Approval Tests 3m
- Summary, Resources, and Further Learning 2m