O'Reilly logo

Learning C# 2005, 2nd Edition by Brian MacDonald, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Real-World Application

To see how Windows Forms can be used to create a more realistic Windows application, you’ll build a utility named FileCopier that copies all files from a group of directories selected by the user to a single target directory or device, such as a floppy or backup hard drive on the company network. Although you won’t implement every possible feature, this example will provide a good introduction to what it is like to build meaningful Windows applications.

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-8.

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)

The FileCopier user interface

Figure 18-8. The FileCopier user interface

The goal is to allow the user to check files (or entire directories) in the left tree view (source). If the user clicks the Copy button, the files checked on the left side will be copied to the Target Directories specified on the right-side control. If the user clicks Delete, the checked files will be deleted.

Tip

The example you’re about to create is much more ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required