October 2003
Intermediate to advanced
736 pages
15h 25m
English
Imagine setting the background image of a form in your application by loading a bitmap from a file:
Public Sub New()
...
' Load a file from the file system
Me.BackgroundImage = _
New Bitmap("C:\WINDOWS\Web\Wallpaper\Azul.jpg")
End Sub
The problem with this code is that not all installations of Windows will have Azul.jpg, and even those that do have it may not have it in the same place. Even if you shipped this picture with your application, a space-conscious user may decide to remove it, causing your application to fault. The only safe way to make sure that the picture, or any file, stays with code is to embed it and load it as a resource, a named piece of data embedded in the assembly itself.
Resources are ...