System.Configuration


.NET Framework Class Library
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)

Syntax

Visual Basic (Declaration)
Public Enumeration ConfigurationUserLevel
Visual Basic (Usage)
Dim instance As ConfigurationUserLevel
C#
public enum ConfigurationUserLevel
C++
public enum class ConfigurationUserLevel
J#
public enum ConfigurationUserLevel
JScript
public enum ConfigurationUserLevel
Members

 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. 
Remarks

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.

Example

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

Visual Basic
 ' Modify a custom section. Show how to use the
 ' OpenExeConfiguration(ConfigurationUserLevel) method.
Shared Sub ModifyCustomSection()
   ' Get the application configuration file.
     Dim config As System.Configuration.Configuration = _
     ConfigurationManager.OpenExeConfiguration( _
     ConfigurationUserLevel.None)
   
   Console.WriteLine(config.FilePath)
   
     Dim custSection As CustomSection = _
     config.Sections(customSectionName)
   
   custSection.FileName = "newName.txt"
   custSection.MaxIdleTime = New TimeSpan(0, 15, 0)
   custSection.MaxUsers = custSection.MaxUsers + 10
   
   If Not custSection.ElementInformation.IsLocked Then
      config.Save()
   Else
      Console.WriteLine("Section was locked, could not update.")
   End If
End Sub 'ModifyCustomSection
C#
// 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.");
Platforms

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.

Version Information

.NET Framework

Supported in: 2.0
See Also

Tags :


Page view tracker