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
Dim instance As ConfigurationUserLevel
public enum ConfigurationUserLevel
public enum class ConfigurationUserLevel
public enum ConfigurationUserLevel
public enum ConfigurationUserLevel
| | Member name | Description |
|---|
| None | Get the Configuration that applies to all users. |
| PerUserRoaming | Get the roaming Configuration that applies to the current user. |
| PerUserRoamingAndLocal | Get 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.
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
// 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