Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 2.0
 ConfigurationUserLevel Enumeration
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.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)

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

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.");

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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker