Wei-Meng Lee - C# 2008 Programmer's Reference

Здесь есть возможность читать онлайн «Wei-Meng Lee - C# 2008 Programmer's Reference» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Indianapolis, Год выпуска: 2009, ISBN: 2009, Издательство: Wiley Publishing, Inc., Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

C# 2008 Programmer's Reference: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «C# 2008 Programmer's Reference»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

C# 2008 Programmers Reference provides a concise and thorough reference on all aspects of the language. Each chapter contains detailed code samples that provide a quick and easy way to understand the key concepts covered.

C# 2008 Programmer's Reference — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «C# 2008 Programmer's Reference», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

□ FTP Server name/IP address

□ Username

□ Password

Because this information is needed every time the user uses the application, it would be helpful to save it 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 application settings allows you to store information persistently in a structured manner without resorting to using a database or forcing you to manually save it to a file. So let's see how application settings can help you in this instance.

Right-click on the PhotoViewerproject 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 167 As their names suggest FTPServerstores the name or IP address - фото 262

Figure 16-7

As their names suggest, FTP_Serverstores the name or IP address of the FTP server, UserNamestores 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 168 The Settingssettingsfile refers to the Settings page that you - фото 263

Figure 16-8

The Settings.settingsfile refers to the Settings page that you have been using to add the application settings. The Settings.Designer.csfile 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;

}

}

[global::System.Configuration.UserScopedSettingAttribute()]

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

[global::System.Configuration.DefaultSettingValueAttribute("ftp://127.0.0.1")]

public string FTP_SERVER {

get {

return ((string)(this["FTP_SERVER"]));

}

set {

this["FTP_SERVER"] = value;

}

}

[global::System.Configuration.UserScopedSettingAttribute()]

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

[global::System.Configuration.DefaultSettingValueAttribute("anonymous")]

public string UserName {

get {

return ((string)(this["UserName"]));

}

set {

this["UserName"] = value;

}

}

[global::System.Configuration.UserScopedSettingAttribute()]

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

[global::System.Configuration.DefaultSettingValueAttribute("password")]

public string Password {

get {

return ((string)(this["Password"]));

}

set {

this["Password"] = value;

}

}

}

}

The app.configfile is an XML File containing the default values of your application settings. Its content is:

ftp://127.0.0.1

anonymous

password

The highlighted code shows the settings that you added earlier and their default values. When the project is compiled, this app.configfile will be named .exe.configand stored in the bin\Debug (or bin\Release) folder of the project. For this project, the filename will be PhotoViewer.exe.config.

During runtime, any changes made to the application settings' values will cause a user.config file to be created in the following folder:

C:\Documents and Settings\\.vshost.exe_Url_iwwpinbgs0makur33st4vnin2nkwxgq1\\

Notice the long string of random characters in the path. The folder name is generated by the system, and each time you have a different folder name.

For this project, the user.configfile will be stored in a folder with a name like this:

C:\Documents and Settings\Wei-Meng Lee\Local Settings\Application Data\PhotoViewer\PhotoViewer.vshost.exe_Url_iwwpinbgs0makur33st4vnin2nkwxgq1\1.0.0.0

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «C# 2008 Programmer's Reference»

Представляем Вашему вниманию похожие книги на «C# 2008 Programmer's Reference» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «C# 2008 Programmer's Reference»

Обсуждение, отзывы о книге «C# 2008 Programmer's Reference» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x