SectionInformation.ForceSave プロパティ
アセンブリ: System.Configuration (system.configuration.dll 内)
構文
Dim instance As SectionInformation Dim value As Boolean value = instance.ForceSave instance.ForceSave = value
/** @property */ public boolean get_ForceSave () /** @property */ public void set_ForceSave (boolean value)
関連付けられている ConfigurationSection オブジェクトが変更されていない場合も保存される場合は true。それ以外の場合は false。既定値は false です。
ConfigurationSection オブジェクトの ForceSave プロパティを使用する方法の例を次に示します。
' Create a section whose name is ' MyUrls that contains a nested collection as ' defined by the UrlsSection class. Shared Sub CreateSection() Dim sectionName As String = "MyUrls" Try ' Get the current configuration file. Dim config _ As System.Configuration.Configuration = _ ConfigurationManager.OpenExeConfiguration( _ ConfigurationUserLevel.None) Dim urlsSection As UrlsSection ' Create the section whose name ' attribute isMyUrls in ' <configSections>. ' Also, create the related target section ' MyUrls in <configuration>. If config.Sections(sectionName) Is Nothing Then urlsSection = New UrlsSection() ' Change the default values of ' the simple element. urlsSection.Simple.Name = "Contoso" urlsSection.Simple.Url = "http://www.contoso.com" urlsSection.Simple.Port = 8080 config.Sections.Add(sectionName, urlsSection) urlsSection.SectionInformation.ForceSave = True config.Save(ConfigurationSaveMode.Full) End If Catch e As ConfigurationErrorsException Console.WriteLine("[CreateSection: {0}]", e.ToString()) End Try End Sub 'CreateSection
// Create a section whose name is // MyUrls that contains a nested collection as // defined by the UrlsSection class. static void CreateSection() { string sectionName = "MyUrls"; try { // Get the current configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); UrlsSection urlsSection; // Create the section whose name attribute // is MyUrls in <configSections>. // Also, create the related target section // MyUrls in <configuration>. if (config.Sections[sectionName] == null) { urlsSection = new UrlsSection(); // Change the default values of // the simple element. urlsSection.Simple.Name = "Contoso"; urlsSection.Simple.Url = "http://www.contoso.com"; urlsSection.Simple.Port = 8080; config.Sections.Add(sectionName, urlsSection); urlsSection.SectionInformation.ForceSave = true; config.Save(ConfigurationSaveMode.Full); } } catch (ConfigurationErrorsException e) { Console.WriteLine("[CreateSection: {0}]", e.ToString()); } }
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- SectionInformation.ForceSave プロパティのページへのリンク