Once an application is updated, the user has a choice to roll it back to its previous version. To do so, go to the Control Panel and run the Add or Remove Programs application. Locate the application (in this case, PhotoViewer) and click on the Change/Remove button. You have two choices — restore the application to its previous state or remove the application from the computer (see Figure 16-29).

Figure 16-29
An application can be rolled back only to its previous version. If it's been updated several times, it only rolls back to the version preceding the last update.
Under the Hood: Application and Deployment Manifests
When you use the Publish Wizard to publish your application using ClickOnce, Visual Studio 2008 publishes your application to the URL that you have indicated. For example, if you specified http://localhost/PhotoViwer/ as the publishing directory and your web publishing directory is C:Inetpubwwwroot, then the virtual directory PhotoViewer will be mapped to the local path C:InetpubwwwrootPhotoViewer.
Two types of files will be created under the C:InetpubwwwrootPhotoViewer directory:
□ Application Manifest
□ Deployment Manifest
The next two sections take a closer look at these two types of files.
When you publish your application, three files and a folder are created in the publishing directory (see Figure 16-30):
□ Application Files — Folder containing the deployment files.
□ A publish.htm
web page — This contains instructions on how to install the application.
□ Application manifest — PhotoViewer.application
. This is the file that is referenced by the publish.htm file. An application manifest is an XML file that contains detailed information about the current application as well as its version number. Chapter 15 has more about application manifests.
□ setup.exe
— A setup application that installs the application onto the target computer.

Figure 16-30
The Application Files folder contains the various versions of the application that have been published (see Figure 16-31).

Figure 16-31
When you republish your application using ClickOnce, the content of PhotoViewer.application
, publish.htm
, and setup.exe
are modified, and one new application manifest is created inside a new folder (for instance, PhotoViewer_1_0_0_6
; located within the Application Files folder), containing the new version of deployment files, will be created.
As mentioned, the PhotoViewer.application
application manifest is an XML file that contains detailed information about the current application as well as its version number. It allows the client to know if he needs to update his application.
The deployment manifest — PhotoViewer.exe.manifest
, in this example — is located in the C:InetpubwwwrootPhotoViewerApplication FilesPhotoViewer_1_0_0_6 directory (assuming that the latest version published is 1.0.0.6; see Figure 16-32). It contains detailed information about the application (such as dependencies and attached files).

Figure 16-32
The PhotoViewer.exe.deploy
file is the executable of your application. Other files in the same directory may include files/databases used by your application. During installation these files will be deployed (downloaded) onto the user's machine.
When the user installs an application onto his computer via ClickOnce, he does not have a choice of where to store the application. In fact, the application is stored on a per-user basis, and different versions of the application are stored in different folders. For example, when I installed the example application on my computer, the application files were stored in:
C:Documents and SettingsWei-Meng LeeLocal SettingsApps2.0JGEG6REQ.YQK C2N9O65K.16Dphot..tion_4f46313378dcdeb5_0001.0000_ff3a6bf346a40e4d
Generally, application files are stored in subdirectories under the C:Documents and Settings
//---ExecutablePath includes the executable name---
string path = Application.ExecutablePath;
//---Strip away the executable name---
path = path.Substring(0, path.LastIndexOf(@''));
Summary
This chapter explained how to develop a Windows application to upload and download pictures to and from an FTP server. Several Windows Forms controls were used to build the application's user interface, and you saw how to use the application settings feature in .NET to preserve the status of an application even after it has exited. Finally, the application was deployed using the ClickOnce, which allows applications to be easily updated after they have been deployed.
Chapter 17
Developing ASP.NET Web Applications
ASP.NET (Active Server Pages .NET) is a web development technology from Microsoft. Part of the .NET Framework, ASP.NET enables developers to build dynamic web applications and Web Services using compiled languages like VB.NET and C#. Developers can use Visual Studio 2008 to develop compelling web applications using ASP.NET, with the ease of drag-and-drop server controls. The latest version of ASP.NET is version 3.5.
This chapter explains how to:
□ Display database records using a server control call GridView
□ Perform data binding in an ASP.NET application using the new LinqDataSource
control
□ AJAX-enable your application by using the new AJAX framework in ASP.NET 3.5 and the AJAX