This documentation is archived and is not being maintained.
ConfigurationElement.IsReadOnly Method
Visual Studio 2008
Gets a value indicating whether the ConfigurationElement object is read-only.
Assembly: System.Configuration (in System.Configuration.dll)
Return Value
Type: System.Booleantrue if the ConfigurationElement object is read-only; otherwise, false.
The following example shows how to use the IsReadOnly method. It is used on a custom section and returns false.
// Show how to use IsReadOnly. // It loops to see if the elements are read only. static void ReadOnlyElements() { try { // Get the configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); // Get the MyUrls section. UrlsSection myUrlsSection = config.GetSection("MyUrls") as UrlsSection; UrlsCollection elements = myUrlsSection.Urls; IEnumerator elemEnum = elements.GetEnumerator(); int i = 0; Console.WriteLine(elements.Count.ToString()); while (elemEnum.MoveNext()) { Console.WriteLine("The element {0} is read only: {1}", elements[i].Name, elements[i].IsReadOnly().ToString()); i += 1; } } catch (ConfigurationErrorsException err) { Console.WriteLine("[ReadOnlyElements: {0}]", err.ToString()); } }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: