Working with Files in C#
Reading and writing data to streams and files is central to many .NET applications, but it can be confusing. This course will teach you how to perform essential file operations and read and write text, binary, and CSV data to streams and files.
What you'll learn
Reading and writing data is central to many .NET applications, but it can be difficult to know which approach to take. In this course, Working with Files in C# , you’ll gain the ability to read and write data and manage files. First, you’ll explore how to manage files and directories stored on disk. Next, you’ll discover how to monitor and respond to changes in the file system. Finally, you’ll learn how to read, process, and write data in text, binary, and CSV formats. When you’re finished with this course, you’ll have the skills and knowledge of C# files and streams needed to read, write, and process data in your C# applications.
Table of contents
- Introduction 2m
- Creating a New Console App 7m
- 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 3m
- Changing a Filename Extension 3m
- Deleting a Directory 3m
- Enumerating All the Files in a Directory 4m
- Summary 2m
- 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 5m
- Automatically Processing Created Files 3m
- Automatically Processing Changed Files 3m
- Ignoring Duplicate FileSystemWatcher Events with a ConcurrentDictionary 6m
- Ignoring Duplicate FileSystemWatcher Events with a MemoryCache 7m
- 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 9m
- FileStreamOptions Properties 4m
- Simplifying StreamReader and StreamWriter Creation 2m
- Selectively Processing Part of Stream 1m
- Using Streams to Read and Write Binary Data 4m
- Using BinaryReader and BinaryWriter 6m
- Specifying Text Encodings 1m
- Using Streams to Append Data 1m
- Random FileStream Access 3m
- MemoryStream Overview 1m
- Asynchronous Streams 3m
- Thread-safe File IO 3m
- Summary 2m
- Introduction 2m
- 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 2m
- 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 2m
- Summary 2m
- Introduction 1m
- The Problems with Testing File Access Code 2m
- An Overview of System.IO.Abstractions 2m
- Refactoring for Testability 7m
- Adding a TextFileProcessor Test 8m
- Adding a BinaryFileProcessor Test 3m
- Adding a CsvFileProcessor Test 3m
- Asserting Mock File Output with Approval Tests 5m
- Summary, Resources, and Further Learning 2m