Configuration.Save Bug?

  • Thread starter Thread starter kramii
  • Start date Start date
K

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
 
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
 
Back
Top