AppSettingsSection クラス
アセンブリ: System.Configuration (system.configuration.dll 内)


appSettings 構成セクションは、アプリケーションの string 値のキーと値のペアを提供します。AppSettingsSection オブジェクトのインスタンスを使用してこれらの値にアクセスするのではなく、ConfigurationManager クラスの AppSettings プロパティ、または WebConfigurationManager クラスの AppSettings プロパティを使用する必要があります。

AppSettingsSection オブジェクトを ConfigurationManager クラスのプロパティとして使用する方法を次のコード例に示します。
Imports System.Configuration Imports System.Collections.Specialized Module UsingAppSettingsSection Sub ShowAppSettings() Dim names As String() = ConfigurationManager.AppSettings.AllKeys Dim appStgs As NameValueCollection = ConfigurationManager.AppSettings Dim i As Integer For i = 0 To appStgs.Count - 1 Console.WriteLine("#{0} Name: {1} Value: {2}", _ i, names(i), appStgs(i)) Next End Sub Sub Main() ' Uncomment the following line to set My.User to the currently logged on Windows user. ' My.User.InitializeWithWindowsUser Console.WriteLine("Application Settings Before:") ShowAppSettings() Console.WriteLine() Console.WriteLine("Add an Application Setting.") ' Get the count of the Application Settings. Dim appStgCnt As Integer = ConfigurationManager.AppSettings.Count Dim asName As String = "AppStg" + appStgCnt.ToString() ' Get the configuration file. Dim config As Configuration = _ ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) ' Add an Application Setting. config.AppSettings.Settings.Add(asName, _ DateTime.Now.ToLongDateString() + " " + _ DateTime.Now.ToLongTimeString()) ' Save the configuration file. config.Save(ConfigurationSaveMode.Modified) ' Force a reload of a changed section. ConfigurationManager.RefreshSection("appSettings") Console.WriteLine() Console.WriteLine("Application Settings After:") ShowAppSettings() Console.WriteLine() ' Show the value of a named Application Setting. Console.WriteLine( _ "The value of application setting {0} is '{1}'.", _ asName, ConfigurationManager.AppSettings(asName)) Console.WriteLine() Console.WriteLine("Press 'Enter' to exit.") Console.ReadLine() End Sub End Module
using System; using System.Collections.Specialized; using System.Configuration; namespace ConfigurationSamples { class UsingAppSettingsSection { static void ShowAppSettings() { string[] names = ConfigurationManager.AppSettings.AllKeys; NameValueCollection appStgs = ConfigurationManager.AppSettings; for (int i = 0; i < appStgs.Count; i++) { Console.WriteLine("#{0} Name: {1} Value: {2}", i, names[i], appStgs[i]); } } static void Main(string[] args) { Console.WriteLine("Application Settings Before:"); ShowAppSettings(); Console.WriteLine(); Console.WriteLine("Add an Application Setting."); // Get the count of the Application Settings. int appStgCnt = ConfigurationManager.AppSettings.Count; string asName = "AppStg" + appStgCnt.ToString(); // Get the configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Add an Application Setting. config.AppSettings.Settings.Add(asName, DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString()); // Save the configuration file. config.Save(ConfigurationSaveMode.Modified); // Force a reload of a changed section. ConfigurationManager.RefreshSection("appSettings"); Console.WriteLine(); Console.WriteLine("Application Settings After:"); ShowAppSettings(); Console.WriteLine(); // Show the value of a named Application Setting. Console.WriteLine( "The value of application setting {0} is '{1}'.", asName, ConfigurationManager.AppSettings[asName]); Console.WriteLine(); Console.WriteLine("Press 'Enter' to exit."); Console.ReadLine(); } } }

System.Configuration.ConfigurationElement
System.Configuration.ConfigurationSection
System.Configuration.AppSettingsSection


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


AppSettingsSection コンストラクタ
アセンブリ: System.Configuration (system.configuration.dll 内)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


AppSettingsSection プロパティ

名前 | 説明 | |
---|---|---|
![]() | ElementInformation | ConfigurationElement オブジェクトのカスタマイズできない情報と機能を格納する ElementInformation オブジェクトを取得します。 ( ConfigurationElement から継承されます。) |
![]() | File | 追加設定の指定、または appSettings 要素で指定された設定のオーバーライドを行う構成ファイルを取得または設定します。 |
![]() | LockAllAttributesExcept | ロックされている属性のコレクションを取得します。 ( ConfigurationElement から継承されます。) |
![]() | LockAllElementsExcept | ロックされている要素のコレクションを取得します。 ( ConfigurationElement から継承されます。) |
![]() | LockAttributes | ロックされている属性のコレクションを取得します。 ( ConfigurationElement から継承されます。) |
![]() | LockElements | ロックされている要素のコレクションを取得します。 ( ConfigurationElement から継承されます。) |
![]() | LockItem | 要素がロックされているかどうかを示す値を取得または設定します。 ( ConfigurationElement から継承されます。) |
![]() | SectionInformation | ConfigurationSection オブジェクトのカスタマイズできない情報と機能を格納する SectionInformation オブジェクトを取得します。 ( ConfigurationSection から継承されます。) |
![]() | Settings | 構成ファイルのアプリケーション設定を格納している NameValueCollection コレクションを取得します。 |

AppSettingsSection メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 現在の ConfigurationElement インスタンスを、指定したオブジェクトと比較します。 ( ConfigurationElement から継承されます。) |
![]() | GetHashCode | 現在の ConfigurationElement インスタンスを表す一意の値を取得します。 ( ConfigurationElement から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsReadOnly | ConfigurationElement オブジェクトが読み取り専用かどうかを示す値を取得します。 ( ConfigurationElement から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

AppSettingsSection メンバ
構成システムに appSettings 構成セクションのサポートを提供します。このクラスは継承できません。
AppSettingsSection データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | ElementInformation | ConfigurationElement オブジェクトのカスタマイズできない情報と機能を格納する ElementInformation オブジェクトを取得します。 (ConfigurationElement から継承されます。) |
![]() | File | 追加設定の指定、または appSettings 要素で指定された設定のオーバーライドを行う構成ファイルを取得または設定します。 |
![]() | LockAllAttributesExcept | ロックされている属性のコレクションを取得します。(ConfigurationElement から継承されます。) |
![]() | LockAllElementsExcept | ロックされている要素のコレクションを取得します。(ConfigurationElement から継承されます。) |
![]() | LockAttributes | ロックされている属性のコレクションを取得します。 (ConfigurationElement から継承されます。) |
![]() | LockElements | ロックされている要素のコレクションを取得します。(ConfigurationElement から継承されます。) |
![]() | LockItem | 要素がロックされているかどうかを示す値を取得または設定します。(ConfigurationElement から継承されます。) |
![]() | SectionInformation | ConfigurationSection オブジェクトのカスタマイズできない情報と機能を格納する SectionInformation オブジェクトを取得します。 (ConfigurationSection から継承されます。) |
![]() | Settings | 構成ファイルのアプリケーション設定を格納している NameValueCollection コレクションを取得します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 現在の ConfigurationElement インスタンスを、指定したオブジェクトと比較します。 (ConfigurationElement から継承されます。) |
![]() | GetHashCode | 現在の ConfigurationElement インスタンスを表す一意の値を取得します。 (ConfigurationElement から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsReadOnly | ConfigurationElement オブジェクトが読み取り専用かどうかを示す値を取得します。 (ConfigurationElement から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- AppSettingsSectionのページへのリンク