Creating a Windows Forms Application
To see how Windows
Forms can be used to create a more realistic Windows application, in
this section 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,
you can imagine programming this application so that you can mark
dozens of files and have them copied to multiple disks, packing them
as tightly as possible. You might even extend the application to
compress the files. The true goal of this example is for you to
exercise many of the C# skills learned in earlier chapters and to
explore the
Windows.Forms
namespace.
For the purposes of this example and to keep the code simple, focus on the user interface and the steps needed to wire up its various controls. The final application UI is shown in Figure 13-7.

Figure 13-7. The FileCopier user interface
The user interface for FileCopier consists of the
following controls:
Labels: Source Files and Target Directory
Buttons: Clear, Copy, Delete, and Cancel
An Overwrite if exists checkbox
A text box displaying the path of the selected target directory
Two large tree-view controls, one for available source directories and one for available target devices and directories
The goal is to allow the user ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access