Working with Files in C# 10
https://www.pluralsight.com/courses/c-sharp-10-working-files
by Jason Roberts
Course Overview
- Course Overview
- Sandbox
Managing Files and Directories
- Introduction
- Creating a New Console App
- Checking if a File Exists
- you can use to check if file path is an absolute path: Path.IsPathFullyQualified
- Getting the Parent Directory of a Path
- Checking if a Directory Exists and Creating New Directories
- Copying a File
- Moving a File
- Getting the File Extension from a File Name
- Checkpoint 01- Get the Parent Directory for a Path
- Changing a Filename Extension
- Checkpoint 02 - Get the Extension Part of a Filename
- Deleting a Directory
- Enumerating All the Files in a Directory
- Summary
- Exercise 01- Copying and Deleting Files
Monitoring the File System for Changes
- Introduction
- Introducing the FileSystemWatcher Class
- The IntemalBufferSize Property
- Configuring Notification Filters
- Additional Properties
- Refactoring to Use a FileSystemWatcher
- use FileSystemWatcher to watch for file changes in a folder
- Checkpoint 03 - Define a New FileSystemWatcher Instance in Code
- Observing the FileSystemWatcher Events
- Automatically Processing Created Files
- Automatically Processing Changed Files
- Checkpoint 04 - Set a FileSystemWatcher to notify solely on file name changes
- Ignoring Duplicate FileSystemWatcher Events with a ConcurrentDictionary
- Ignoring Duplicate FileSystemWatcher Events with a MemoryCache
- Adding Existing File Processing
- FileSystemWatcher Testing Considerations
- Summary
Reading and Writing Entire Files Into Memory
- Introduction
- Reading and Writing Text Files
- Checkpoint 05 - Use the File class to read all the text from a file into a string
- Reading and Writing Text Files with String Arrays
- Checkpoint 06 - Use the File class to write a string instance to a text file
- Specifying Text Encodings
- Appending Text Content
- Reading and Writing the Entire Contents of Binary Files
- Checkpoint 07 - Use the File class to read binary data from a file into a byte array
- Considerations
- Summary
- Exercise 03 - Write a simple app to read text from a text file, convert it to uppercase, and write it out to a new file
Reading and Writing Data Incrementally Using Streams
- Introduction
- An Introduction to Streams
- The Benefits of Streams
- .NET Class Hierarchy Overview
- Using Streams to Read and Write Text Content
- FileStreamOptions Properties
- Simplifying Stream Reader and StreamWriter Creation
- Checkpoint 08 - Use a static method on the File class to define a StreamReader instance
- Checkpoint 09 - Define a StreamWriter instance for a given file path
- Selectively Processing Part of Stream
- Using Streams to Read and Write Binary Data
- Using BinaryReader and BinaryWriter
- Checkpoint 10 - Define a FileStream instance using a static File method to read data
- Specifying Text Encodings
- Using Streams to Append Data
- Random FileStream Access
- MemoryStream Overview
- Asynchronous Streams
- Thread-safe File IO
- Summary
- Exercise 04 - Create a simple application to read binary data one byte at a time using a stream
Reading and Writing CSV Data
- Introduction
- An Overview of the CsvHelper Library
- Reading CSV Data Dynamically
- Checkpoint 11 - Define a CsvConfiguration that uses an invariant culture
- Checkpoint 12 - Use CsvHelper to read all the records in a CSV file as dynamic data
- Configuring CSV Comment Reading
- Configuring Trimming of Whitespace
- Configuring CSV Blank Line Handling
- Configuring CSV File Headers
- Configuring a Custom Delimiter
- Checkpoint 13 - Configure CsvHelper to use a semicolon instead of a comma
- Reading CSV Data in a Strongly Typed Way
- Configuring Custom Class Mapping
- Creating Custom Type Converters
- Configuring Header Validation and Missing Field Actions
- Writing CSV Files
- Summary
- Exercise 05 - Create Strongly typed Classes
Creating Automated Tests for File Access Code
- Introduction
- The Problems with Testing File Access Code
- An Overview of System.lO.Abstractions
- Refactoring for Testability
- Adding a TextFileProcessor Test
- Checkpoint 14 - Create a MockFileData instance containing 3 lines of text
- Adding a BinaryFileProcessor Test
- Checkpoint 15 - Add a file to a MockFileSystem instance
- Adding a CsvFileProcessor Test
- Checkpoint 16 - Add a directory to a MockFileSystem instance
- Checkpoint 17 - Read a file from a MockFileSystem instance
- Asserting Mock File Output with Approval Tests
- Summary, Resources, and Further Leaming
- Exercise 06 - Write a class that abstracts away the physical file system so that it can be unit tested
Comments
Post a Comment