Export (0) Print
Expand All
Expand Minimize
0 out of 4 rated this helpful - Rate this topic

ConfigurationUserLevel Enumeration

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

Used to specify which configuration file is to be represented by the Configuration object returned by OpenExeConfiguration.

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

public enum ConfigurationUserLevel
public enum ConfigurationUserLevel
public enum ConfigurationUserLevel
 Member nameDescription
NoneGet the Configuration that applies to all users. 
PerUserRoamingGet the roaming Configuration that applies to the current user. 
PerUserRoamingAndLocalGet the local Configuration that applies to the current user. 

Use ConfigurationUserLevel to specify which configuration file is to be represented by the Configuration object returned by ConfigurationManager.OpenExeConfiguration and System.Configuration.ConfigurationManager.OpenExeConfiguration.

Application configuration files are in the same directory as the application and have the same name, but with a .config extension. For example, the configuration file for C:\System\Public.exe is C:\System\Public.exe.config.

Applications use a global configuration that applies to all users, separate configurations that apply to individual users, and configurations that apply to roaming users.

The following example shows how to use the ConfigurationUserLevel enumeration. This example is part of a larger example to be found at ConfigurationManager.

// Modify a custom section. Show how to use the
// OpenExeConfiguration(ConfigurationUserLevel) method.
static void ModifyCustomSection()
{
    // Get the application configuration file.
    System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

    Console.WriteLine(config.FilePath);

    CustomSection custSection =
       config.Sections[customSectionName] as CustomSection;

    custSection.FileName = "newName.txt";
    custSection.MaxIdleTime = new TimeSpan(0, 15, 0);
    custSection.MaxUsers = custSection.MaxUsers + 10;

    if (!custSection.ElementInformation.IsLocked)
        config.Save();
    else
        Console.WriteLine("Section was locked, could not update.");


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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.