Creating a Real-World Application

Now you have a general idea of how Windows applications work, and it’s time to get more ambitious and employ what you’ve learned in the previous 17 chapters. You’ll build a utility named FileCopier that copies all the files from a group of directories selected by the user to a single target directory or device, such as a floppy, or a backup hard drive on the company network. Although you won’t implement every possible feature for this application, this example will provide a good introduction to what it is like to build meaningful Windows applications.

Tip

The example you’re about to create is much more complex than anything you’ve done in this book so far. However, if you walk through the code slowly, you’ll find that you’ve already learned everything you need in the previous chapters. The goal of creating Windows applications is to mix drag-and-drop design with rather straightforward C# blocks to handle the logic.

For the purposes of this example and to keep the code simple, you’ll focus on the user interface and the steps needed to wire up its various controls. The final application UI is shown in Figure 18-7.

The user interface for FileCopier consists of the following controls:

  • Labels (Source Files, Target Files, and Status).

  • Buttons (Clear, Copy, Delete, and Cancel).

  • An “Overwrite if exists” checkbox.

  • A text box displaying the path of the selected target directory.

  • TreeView controls (source and target directories). You may not be familiar with the ...

Get Learning C# 3.0 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.