Skip to content

Commit 36363e1

Browse files
Merge pull request #49814 from wwlpublish/b01279e8c43c169068f94f2f4523fcd7cbf4b41707dff12424630d93fb4b1a7a-live
Modules/M01-get-started-file-input-output
2 parents 1c9ee3e + 638b222 commit 36363e1

19 files changed

+1260
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.introduction
3+
title: Introduction
4+
metadata:
5+
title: Introduction
6+
description: "Introduction."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 3
12+
content: |
13+
[!include[](includes/1-introduction.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.examine-text-file-formats-tools
3+
title: Examine text file formats and tools
4+
metadata:
5+
title: Examine text file formats and tools
6+
description: "Examine text file formats and tools."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 8
12+
content: |
13+
[!include[](includes/2-examine-text-file-formats-tools.md)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.manage-local-directories-files-directory-file-path-classes
3+
title: Manage local directories and files using the Directory, File, and Path classes
4+
metadata:
5+
title: Manage local directories and files using the Directory, File, and Path classes
6+
description: "Manage local directories and files using the Directory, File, and Path classes."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 9
12+
content: |
13+
[!include[](includes/3-manage-local-directories-files-directory-file-path-classes.md)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.read-write-text-files-streamreader-streamwriter-classes
3+
title: Read and write text files using the StreamReader and StreamWriter classes
4+
metadata:
5+
title: Read and write text files using the StreamReader and StreamWriter classes
6+
description: "Read and write text files using the StreamReader and StreamWriter classes."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 10
12+
content: |
13+
[!include[](includes/4-read-write-text-files-streamreader-streamwriter-classes.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.control-file-access-filestream-class
3+
title: Control file access using the FileStream class
4+
metadata:
5+
title: Control file access using the FileStream class
6+
description: "Control file access using the FileStream class."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 9
12+
content: |
13+
[!include[](includes/5-control-file-access-filestream-class.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.examine-binaryreader-binarywriter-classes
3+
title: Examine the BinaryReader and BinaryWriter classes
4+
metadata:
5+
title: Examine the BinaryReader and BinaryWriter classes
6+
description: "Examine the BinaryReader and BinaryWriter classes."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 7
12+
content: |
13+
[!include[](includes/6-examine-binaryreader-binarywriter-classes.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.exercise-create-manage-text-files
3+
title: Exercise - Create and manage text files
4+
metadata:
5+
title: Exercise - Create and manage text files
6+
description: "Exercise - Create and manage text files."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 30
12+
content: |
13+
[!include[](includes/7-exercise-create-manage-text-files.md)]
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.knowledge-check
3+
title: Knowledge check
4+
metadata:
5+
title: Knowledge check
6+
description: "Knowledge check."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 3
12+
quiz:
13+
title: "Check your knowledge"
14+
questions:
15+
- content: "What does the `Directory.GetFiles` method in C# return?"
16+
choices:
17+
- content: "It returns the size of the specified directory."
18+
isCorrect: false
19+
explanation: "Incorrect.` Directory.GetFiles` doesn't provide information about the size of a directory."
20+
- content: "It returns the names of subdirectories within the specified directory."
21+
isCorrect: false
22+
explanation: "Incorrect. Returning subdirectories is the behavior of `Directory.GetDirectories`, not `Directory.GetFiles`."
23+
- content: "It returns the names of files within the specified directory."
24+
isCorrect: true
25+
explanation: "Correct. `Directory.GetFiles` returns an array of full file names including paths."
26+
- content: "What is the purpose of the `StreamReader` and `StreamWriter` classes in C#?"
27+
choices:
28+
- content: "They're used to establish network connections for data transmission."
29+
isCorrect: false
30+
explanation: "Incorrect. `StreamReader` and `StreamWriter` are used for handling text data in streams, not for establishing network connections."
31+
- content: "They're used to read and write binary data from and to a stream."
32+
isCorrect: false
33+
explanation: "Incorrect. `StreamReader` and `StreamWriter` are designed for reading and writing text data, not binary data."
34+
- content: "They're used to read characters from a byte stream and write characters to a stream in a specific encoding."
35+
isCorrect: true
36+
explanation: "Correct. The `StreamReader` class is used to read characters from a byte stream in a particular encoding, while the `StreamWriter` class is used to write characters to a stream in a specific encoding."
37+
- content: "What is the purpose of the `FileStream.Seek` method in C#?"
38+
choices:
39+
- content: "It's used to write to a file."
40+
isCorrect: false
41+
explanation: "Incorrect. The `FileStream.Seek` method doesn't write to a file."
42+
- content: "It's used to change the current position of the `FileStream` object."
43+
isCorrect: true
44+
explanation: "Correct. The `FileStream.Seek` method changes the current position of the `FileStream` object."
45+
- content: "It's used to close a file."
46+
isCorrect: false
47+
explanation: "Incorrect. The `FileStream.Seek` method doesn't close a file."
48+
- content: "What are some common use cases for the `BinaryReader` and `BinaryWriter` classes in .NET?"
49+
choices:
50+
- content: "They're used for creating and managing databases."
51+
isCorrect: false
52+
explanation: "Incorrect. While they can handle data, `BinaryReader` and `BinaryWriter` aren't designed for database management."
53+
- content: "They're used for handling binary data such as configuration and multimedia files."
54+
isCorrect: true
55+
explanation: "Correct. `BinaryReader` and `BinaryWriter` are designed for reading and writing binary data, which includes configuration and multimedia files."
56+
- content: "They're used for reading and writing text files."
57+
isCorrect: false
58+
explanation: "Incorrect. `BinaryReader` and `BinaryWriter` aren't typically used for text files."
59+
- content: "What classes are used to create and manage directories and files in a C# app?"
60+
choices:
61+
- content: "`BinaryWriter` and `BinaryReader` classes."
62+
isCorrect: false
63+
explanation: "Incorrect. These classes are used for creating and reading binary files."
64+
- content: "`Path`, `Directory`, and `File` classes."
65+
isCorrect: true
66+
explanation: "Correct. The Path, Directory, and File classes are used to create and manage directories and files."
67+
- content: "`StreamWriter`, `StreamReader`, and `FileStream` classes."
68+
isCorrect: false
69+
explanation: "Incorrect. These classes are used for reading and writing CSV files and performing low-level file input and output operations."
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.get-started-file-input-output.summary
3+
title: Summary
4+
metadata:
5+
title: Summary
6+
description: "Summary."
7+
ms.date: 04/03/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 2
12+
content: |
13+
[!include[](includes/9-summary.md)]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
File input and output (File I/O) are an important programming task that enables your applications to persist, retrieve, and exchange application data. In this module, you learn how to manage text files in C#, including how to create, read, write, and delete local text files and directories using classes in the `System.IO` namespace. You also learn how to work with structured and unstructured data types, and how to use common text file formats.
2+
3+
Imagine you're signed up to help a non-profit company with a software project. Before the project kicks off, you decide to update your programming skills by developing a banking app. To practice your file management skills, you plan to implement file input and output operations within the app's Program.cs file. You plan to work you way through some basic directory and file management tasks and then finish up with more advanced tasks like storing and retrieving bank transactions.
4+
5+
The topics covered in this module include:
6+
7+
- Get started with file input and output.
8+
- Manage local directories, files, and paths.
9+
- Read and write text files using the `StreamReader` and `StreamWriter` classes.
10+
- Control file access using the `FileStream` class.
11+
- Examine the `BinaryReader` and `BinaryWriter` classes.
12+
13+
After completing this module, you're able to:
14+
15+
- Describe common file I/O operations, the difference between structured and unstructured data, common text file formats, and classes in the `System.IO` namespace.
16+
- Use the `Path`, `Directory`, and `File` classes to create, copy, move, delete, and enumerate local text files and directories.
17+
- Implement file I/O operations using the `StreamReader` and `StreamWriter` classes and CSV files.
18+
- Control file access using the `FileStream` class.
19+
- Read and write binary files using the `BinaryReader` and `BinaryWriter` classes.
20+
- Store and retrieve C# objects using file input and output operations.
21+
22+
By the end of this module, you have a solid understanding of file I/O operations and how to implement local file I/O in your projects. You're able to create, read, write, delete, and enumerate files and directories. You also have a better understanding of the different types of file formats and how to work with them effectively.

0 commit comments

Comments
 (0)