Resources

The .config file, dynamic properties, files in special folders, and isolated storage all provide data used to control an application's look and feel, as well as its behavior, while remaining separate from the code itself. One other major place for this kind of data for applications and controls is resources. A resource is a named piece of data bound into the EXE or DLL at build time. For example, you could set the background image of a form in your application by loading a bitmap from a file:

public MainForm() {
  InitializeComponent();
  this.BackgroundImage =
					new Bitmap(@"C:\WINDOWS\Web\Wallpaper\Azul.jpg");
}

The problem with this code, of course, is that not all installations of Windows will have Azul.jpg, and even those that have ...

Get Windows Forms Programming in C# 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.