When .NET first came to life, there were two ways to create applications: ASP.NET for web applications, and Windows Forms for Windows applications. Although WPF offers many advantages over Windows Forms, Microsoft realizes that there are a great many Windows Forms applications already up, tested, and working, and that many companies will choose to maintain and extend them.
Our interest in this book is how we can use C# to interact with Windows Forms, and in this chapter we'll look at building a nontrivial application using this technology. Figure 19-1 shows the application we're going to build. It is a Windows application for copying files from one or more directories to a target directory, written in Windows Forms and designed to be run on a Windows computer (this application has been tested on Windows XP, 2000, and Vista).
Figure 19-1. The File Copier application
Once again, because this is a C# book and not a Windows programming book, we're going to make fast work of the UI and focus on the code-behind file and the event handlers—that is, on the C#. Unlike with WPF, however, there is no declarative aspect to Windows Forms; you create the UI by dragging objects onto a form, and then interacting with those objects by clicking on them and setting their properties, either in the Properties window at design time, or programmatically at ...