SectionInformation.ForceSave Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a value that indicates whether the associated configuration section will be saved even if it has not been modified.

Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)

public bool ForceSave { get; set; 
/** @property */
public boolean get_ForceSave ()

/** @property */
public void set_ForceSave (boolean value)

public function get ForceSave () : boolean

public function set ForceSave (value : boolean)

Property Value

true if the associated ConfigurationSection object will be saved even if it has not been modified; otherwise, false. The default is false.

The following example shows how to use the ForceSave property of a ConfigurationSection object.

// Create a section whose name is 
// MyUrls that contains a nested collection as 
// defined by the UrlsSection class.
static void CreateSection()
    string sectionName = "MyUrls";


        // Get the current configuration file.
        System.Configuration.Configuration config =

        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 =  "";
            urlsSection.Simple.Port = 8080;

            config.Sections.Add(sectionName, urlsSection);
            urlsSection.SectionInformation.ForceSave = true;
    catch (ConfigurationErrorsException e)
        Console.WriteLine("[CreateSection: {0]",

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions