EXERCISE TOPIC▼
C# EXERCISES▼
VISUAL C# EXERCISES▼
- Creating forms (4)
- Coding form events (1)
- Laying out your code (2)
- C# variables (4)
- Enumerations and constants (2)
- Conditions (2)
- Modular code (3)
- Arrays (2)
- Looping (2)
- Files and folders (3)
- Properties in C# (3)
- Using lists (3)
- Validating forms (6)
- Toolbars, menus and status bars (1)
- FileDialogs and StreamReaders (1)
- Debugging and trapping errors (1)
- Introduction to DataGridViews (1)
- DataGridView events (3)
- Complex DataGridViews (2)
- Creating classes (4)
- The form as a class (1)
- Data structures (6)
- Inheritance (5)
- Interfaces (2)
- Delegates and events (2)
- Writing LINQ (2)
- Advanced LINQ (2)
- Entity Frameworks (1)
- LINQ with Entity Frameworks (4)
- Grouping using LINQ (2)
- LINQ to SQL (2)
Visual C# | FileDialogs and StreamReaders exercise | Use a StreamReader and FileDialog
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
You can learn how to do this exercise on the relevant Wise Owl classroom training course (sadly for the moment only in the UK).
Software ==> | Visual C# (79 exercises) |
Version ==> | Any version of C# |
Topic ==> | FileDialogs and StreamReaders (1 exercise) |
Level ==> | Average difficulty |
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Someone has hidden the word Kilroy in one of the forms in the folder above - your task is to find it! First, create a form called frmHuntKilroy containing a single clickable button.
Attach code to this button to display an OpenFileDialog, allowing a user to choose one or more code files (use the filter *.cs):

Set the FileDialog's MultiSelect property, to allow multiple file selection
When a user selects one or more code files, extend your code to:
- Open each file using a StreamReader object
- Read through the lines in the file looking for the text Kilroy; then
- Close the file
Eventually you should find the word you're looking for, and display the name of the file in which you found it:

Sorry - you'll have to find out yourself!
That's it!