You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/solutions/io/files.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ tags:
57
57
58
58
#. It does not close the file properly,
59
59
#. It can throw exceptions if e.g., `filePath` cannot be accessed by the program,
60
-
#. It possibly overwrite the file located at `filePath`.
60
+
#. It possibly overwrites the file located at `filePath`.
61
61
62
62
To solve those, it should be edited to:
63
63
@@ -66,6 +66,15 @@ tags:
66
66
#. Either test first if the file exists, or use the `StreamWriter` constructor that appends to the file if it already exists.
67
67
</details>
68
68
69
+
#. Assume that `filePath` contains the path to a text file that is not empty. Write a program that counts its number of lines.
70
+
71
+
<details><summary>Solution</summary>
72
+
```{download="./code/projects/FileLineCount.zip"}
73
+
!include`snippetStart="// in the file we created.",snippetEnd="// We can do a simple check to make sure"` code/projects/FileLineCount/FileLineCount/Program.cs
74
+
```
75
+
</details>
76
+
77
+
69
78
#. Write a program that create a text file called `HelloWorld.txt` in its `bin/Debug` folder and store "Hello" followed by a name entered by the user in it.
0 commit comments