somewhere persistently so that the next time the user launches the application, it's available without his needing to type it in again.
In Windows Forms, a feature known as
Right-click on the PhotoViewer
project in Solution Explorer and select Properties. In the Properties page, click on the Settings tab and enter the three application settings in the following table (see Figure 16-7).
Name | Type | Scope | Value |
---|---|---|---|
FTP_SERVER | string | User | ftp://127.0.0.1 |
UserName | string | User | anonymous |
Password | string | User | password |

Figure 16-7
As their names suggest, FTP_Server
stores the name or IP address of the FTP server, UserName
stores the username used to log in to the FTP server, and Password stores the password used to log in to the FTP server.
Notice the following:
□ The type of each application setting is string. You can also specify other .NET types for each application setting.
□ The scope for each application setting is User. Application settings can be either user-scoped or application-scoped. Application-scoped settings are not discussed because they are beyond the scope of this book.
□ The default value for each application setting is also specified here.
Save the solution in Visual Studio 2008 so that the application settings can be saved.
Let's examine the project a little closer to see how the application settings work. Figure 16-8 shows the three files in Solution Explorer that are used to maintain your application settings (you need to click the Show All Files button in Solution Explorer to view all these files).

Figure 16-8
The Settings.settings
file refers to the Settings page that you have been using to add the application settings. The Settings.Designer.cs
file is a compiler-generated file that contains the data types of the various settings that you have defined. Here are the definitions for the various application settings:
namespace PhotoViewer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
'Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator',
'9.0.0.0')]
internal sealed partial class Settings :
global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance =
((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings ())));
public static Settings Default {
get {
return defaultInstance;
}
}