Home All Groups Group Topic Archive Search About

Configuration.Save Bug?

Author
26 Apr 2006 11:48 AM
kramii
Apparently, if I open a named file using OpenExeConfiguration, modify
it and try to save the file using Configuration.Save, the framework
appends ".config" onto the fileaname. Is this a bug?

Here is part of my test class. There is already a file in my
application's bin directory called BBB.XML. A new file is created
called BBB.XML.config.


Public Shared Function Load() As FtpConfiguration
        If IsNothing(_instance) Then

            _configFile =
ConfigurationManager.OpenExeConfiguration("BBB.XML")

            If IsNothing(_configFile.GetSection("MyNewSection")) Then

                _instance = New FtpConfiguration
                _configFile.Sections.Remove("MyNewSection")
                _configFile.Sections.Add("MyNewSection", _instance)
                _instance.FtpServer = "SERVERNAME"
                _instance.SectionInformation.ForceSave = True
                _configFile.Save() 'As("BBB.XML",
ConfigurationSaveMode.Minimal, True)
                Debug.WriteLine("Configuration created in: " &
_configFile.FilePath)

            Else

                _instance =
CType(_configFile.GetSection("MyNewSection"), FtpConfiguration)

            End If

        End If

        Return _instance
    End Function

Author
1 May 2006 7:59 PM
Mary Chipman [MSFT]
I'm pretty sure that's by design since there doesn't appear to be any
way to control this behavior. By default all configuration files have
a .config file extension. If you want to preserve the XML extension,
then I'd recommend using the classes from System.IO.

--Mary

Show quote
On 26 Apr 2006 04:48:02 -0700, "kramii" <nospamthanks@runbox.com>
wrote:

>Apparently, if I open a named file using OpenExeConfiguration, modify
>it and try to save the file using Configuration.Save, the framework
>appends ".config" onto the fileaname. Is this a bug?
>
>Here is part of my test class. There is already a file in my
>application's bin directory called BBB.XML. A new file is created
>called BBB.XML.config.
>
>
> Public Shared Function Load() As FtpConfiguration
>        If IsNothing(_instance) Then
>
>            _configFile =
>ConfigurationManager.OpenExeConfiguration("BBB.XML")
>
>            If IsNothing(_configFile.GetSection("MyNewSection")) Then
>
>                _instance = New FtpConfiguration
>                _configFile.Sections.Remove("MyNewSection")
>                _configFile.Sections.Add("MyNewSection", _instance)
>                _instance.FtpServer = "SERVERNAME"
>                _instance.SectionInformation.ForceSave = True
>                _configFile.Save() 'As("BBB.XML",
>ConfigurationSaveMode.Minimal, True)
>                Debug.WriteLine("Configuration created in: " &
>_configFile.FilePath)
>
>            Else
>
>                _instance =
>CType(_configFile.GetSection("MyNewSection"), FtpConfiguration)
>
>            End If
>
>        End If
>
>        Return _instance
>    End Function

AddThis Social Bookmark Button