Working with Files and Streams in C#

Working with Files and Streams in C#

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 3h 13m | 621 MB

Understanding file and data manipulation is key to a full understanding of C#. This course will teach you how to manage files and directories, read and write data in a number of different ways, and write unit tests using a mock file system.

At the core of C# file IO is a thorough knowledge of how to manipulate files and directories and use streams. In this course, Working with Files and Streams in C#, you will learn the skills you need to read and write text, binary, and CSV files, and work with streams of data. First, you will learn how to manipulate files and directories on disk. Next, you will discover how to respond to changes in the file system and read and write data by loading entire files into memory or by incrementally processing them with streams. Finally, you will explore how to write testable file IO code and how to use a mock file system to create faster-executing and more maintainable tests. When you’re finished with this course, you will have a foundational understanding of file access and stream manipulation code that will help you immensely as you move forward and create your own file- or stream-manipulating applications.

Table of Contents

Course Overview
1 Course Overview

Managing Files and Directories
2 Introduction
3 Creating a New Console App
4 Checking if a File Exists
5 Getting the Parent Directory of a Path
6 Checking if a Directory Exists and Creating New Directories
7 Copying a File
8 Moving a File
9 Getting the File Extension from a File Name
10 Deleting a Directory
11 Enumerating All the Files in a Directory
12 Summary

Monitoring the File System for Changes
13 Introduction
14 Introducing the FileSystemWatcher Class
15 The InternalBufferSize Property
16 Configuring Notification Filters
17 Additional Properties
18 Refactoring to Use a FileSystemWatcher
19 Observing the FileSystemWatcher Events
20 Automatically Processing Files
21 Ignoring Duplicate FileSystemWatcher Events with a ConcurrentDictionary
22 Ignoring Duplicate FileSystemWatcher Events with a MemoryCache
23 Adding Existing File Processing
24 FileSystemWatcher Testing Considerations
25 Summary

Reading and Writing Entire Files into Memory
26 Introduction
27 Reading and Writing Text Files
28 Reading and Writing Text Files with String Arrays
29 Specifying Text Encodings
30 Appending Text Content
31 Reading and Writing the Entire Contents of Binary Files
32 Considerations
33 Summary

Reading and Writing Data Incrementally Using Streams
34 Introduction
35 An Introduction to Streams
36 The Benefits of Streams
37 NET Class Hierarchy Overview
38 Using Streams to Read and Write Text Content
39 Simplifying StreamReader and StreamWriter Creation
40 Selectively Processing Part of Stream
41 Using Streams to Read and Write Binary Data
42 Using BinaryReader and BinaryWriter
43 Specifying Text Encodings
44 Using Streams to Append Data
45 Random FileStream Access
46 MemoryStream Overview
47 Summary

Reading and Writing CSV Data
48 Introduction
49 An Overview of the CsvHelper Library
50 Reading CSV Data Dynamically
51 Ignoring Blank Lines
52 Configuring a Custom Delimiter
53 Configuring CSV File Headers
54 Reading Data into Entity Classes
55 Configuring Header Validation and Missing Field Actions
56 Configuring Custom Class Mapping
57 Creating Custom Type Converters
58 Writing CSV Files
59 Summary

Creating Automated Tests for File Access Code
60 Introduction
61 The Problems with Testing File Access Code
62 An Overview of System.IO.Abstractions
63 Refactoring for Testability
64 Adding a TextFileProcessor Test
65 Adding a BinaryFileProcessor Test
66 Adding a CsvFileProcessor Test
67 Asserting Mock File Output with Approval Tests
68 Summary Resources and Further Learning