
348
LESSON 29 Reading and WRiting Files
2. Make a program that lets the user select a number from a NumericUpDown control and then
generates a file containing a multiplication table that goes up to that number times itself. Use
formatting to make the numbers line up in columns.
3. Build a program with a TextBox, a ListBox, an Add button, and a Save button. When the
user enters a value in the
TextBox and clicks Add, add the value to the ListBox. When the user
clicks Save, write the values from the
ListBox into a file and then clear the ListBox. When the
form loads, make it read the values back into the
ListBox.
4. Build a simple text editor. Give it a MenuStrip with Open and Save commands and a TextBox.
Use an
OpenFileDialog and a SaveFileDialog to let the user select the file to open and save.
(Don’t worry about any of the other things a real editor would need to handle, such as locked
files and ensuring that the user doesn’t close the program with unsaved changes.)
You can download the solutions to these exercises from the book’s web page at
www.wrox.com or www.CSharpHelper.com/24hour.html. You can find those
solutions in the Lesson29 folder.
596906c29.indd 348 4/7/10 12:34:22 PM
Click here to Play