LocalFileSettingsProvider 类

定义

为应用程序设置类提供持久性存储。Provides persistence for application settings classes.

public ref class LocalFileSettingsProvider : System::Configuration::SettingsProvider, System::Configuration::IApplicationSettingsProvider
public class LocalFileSettingsProvider : System.Configuration.SettingsProvider, System.Configuration.IApplicationSettingsProvider
type LocalFileSettingsProvider = class
    inherit SettingsProvider
    interface IApplicationSettingsProvider
Public Class LocalFileSettingsProvider
Inherits SettingsProvider
Implements IApplicationSettingsProvider
继承
LocalFileSettingsProvider
实现

注解

设置提供程序定义用于存储应用程序设置体系结构中使用的配置数据的机制。Setting providers define a mechanism for storing configuration data used in the application settings architecture. .NET Framework.NET Framework 包含单个默认设置提供程序(LocalFileSettingsProvider),该提供程序将配置数据存储到本地文件系统。The .NET Framework.NET Framework contains a single default settings provider, LocalFileSettingsProvider, which stores configuration data to the local file system. 应用程序设置属性或一组属性通过使用 SettingsProviderAttribute关联到特定的设置提供程序。An application settings property or group of properties are associated to a specific settings provider through the use of the SettingsProviderAttribute.

通常,客户端程序不会显式访问此类;相反,当需要其服务时,应用程序设置体系结构会自动调用相应的设置提供程序。Typically, the client program does not explicitly access this class; rather, the application settings architecture automatically invokes the appropriate settings provider when its services are required. 例如,ApplicationSettingsBase 的许多成员将其工作委托给关联的设置提供程序。For example, many of the members of ApplicationSettingsBase delegate their work to the associated settings provider.

LocalFileSettingsProvider 将设置保存到扩展名为 .config的配置文件中。LocalFileSettingsProvider persists settings to configuration files that have the extension .config. 配置文件的内容结构化为 XML 文档。The contents of configuration files are structured as XML documents. 根据设置的作用域是应用程序级还是用户级,配置数据将分别存储为 <applicationSettings><userSettings> 部分组中的元素。Depending on whether the setting is scoped at either the application-level or user-level, the configuration data is stored as elements within an <applicationSettings> or a <userSettings> section group, respectively. 每个分区组分别由相应的 AppSettingsSectionClientSettingsSection表示。Each of these section groups is represented by a corresponding AppSettingsSection or ClientSettingsSection, respectively. 每个节对象由配置节处理程序拥有和管理,配置节处理程序是 IConfigurationSectionHandler类型的对象。Each section object is owned and administered by a configuration section handler, which is an object of type IConfigurationSectionHandler.

应用程序范围的设置和默认用户范围设置存储在名为 application.exe.config的文件中,该文件在与可执行文件相同的目录中创建。Application-scoped settings and the default user-scoped settings are stored in a file named application.exe.config, which is created in the same directory as the executable file. 应用程序配置设置为只读。Application configuration settings are read-only. 特定用户数据存储在名为 user.config的文件中,该文件存储在用户的主目录下。Specific user data is stored in a file named user.config, stored under the user's home directory. 如果启用了漫游配置文件,则可以存在两个版本的用户配置文件。If roaming profiles are enabled, two versions of the user configuration file could exist. 在这种情况下,漫游版本中的条目优先于本地用户配置文件中的重复项。In such a case, the entries in the roaming version take precedence over duplicated entries in the local user configuration file.

有关应用程序设置的详细信息,请参阅Windows 窗体的应用程序设置For more information about application settings, see Application Settings for Windows Forms.

构造函数

LocalFileSettingsProvider()

初始化 LocalFileSettingsProvider 类的新实例。Initializes a new instance of the LocalFileSettingsProvider class.

属性

ApplicationName

获取或设置当前运行的应用程序的名称。Gets or sets the name of the currently running application.

Description

获取一条简短的易懂描述,它适合在管理工具或其他用户界面 (UI) 中显示。Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).

(继承自 ProviderBase)
Name

获得一个友好名称,用于在配置过程中引用提供程序。Gets the friendly name used to refer to the provider during configuration.

(继承自 ProviderBase)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetPreviousVersion(SettingsContext, SettingsProperty)

返回同一应用程序的早期版本的命名设置属性的值。Returns the value of the named settings property for the previous version of the same application.

GetPropertyValues(SettingsContext, SettingsPropertyCollection)

为指定的应用程序实例和设置属性组返回设置属性值的集合。Returns the collection of setting property values for the specified application instance and settings property group.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Initialize(String, NameValueCollection)

初始化提供程序。Initializes the provider.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Reset(SettingsContext)

将与指定的应用程序关联的所有应用程序设置属性重置为其默认值。Resets all application settings properties associated with the specified application to their default values.

SetPropertyValues(SettingsContext, SettingsPropertyValueCollection)

设置指定的属性设置组的值。Sets the values of the specified group of property settings.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
Upgrade(SettingsContext, SettingsPropertyCollection)

尝试从相同应用程序的早期版本迁移以前的用户范围设置。Attempts to migrate previous user-scoped settings from a previous version of the same application.

适用于

另请参阅