Apply Your Knowledge

Exercises

3.1. Handling Exceptions

Recall that Step by Step 2.5 in Chapter 2 demonstrates the use of common dialog boxes through the creation of a simple rich text editor. This editor allows you to open and save a rich text file. You can also edit the text and change its fonts and colors. The program works fine in all cases except when you try to open or save a file that is already open; in that case, the program throws a System.IO.IOException exception.

The objective of this exercise is to make a robust version of this program that generates a warning about the open file rather than abruptly terminating the program.

Estimated time: 15 minutes

1.
Open a new Windows application in Visual C# .NET. Name it 316C03Exercises

Get MCAD/MCSD.NET Training Guide (Exam 70-316): Developing and Implementing Windows®-Based Applications with Microsoft® Visual C#™ .NET and Microsoft® Visual Studio® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.