2007-11-14 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.Configuration / System.Configuration / Configuration.cs
index 05748bc1c204de0471d73e43245aa2a969af8b7b..9f6a3ae117511a6d8f2c1030543d4a3fb9d25616 100644 (file)
@@ -340,6 +340,8 @@ namespace System.Configuration {
                        section.ConfigHost = system.Host;
                        parentGroup.AddChild (section);
                        elementData [section] = sec;
+
+                       sec.Initialize (this, section);
                }
                
                internal void RemoveConfigInfo (ConfigInfo config)
@@ -364,7 +366,7 @@ namespace System.Configuration {
                        try {
                                Save (stream, mode, forceUpdateAll);
                                system.Host.WriteCompleted (streamName, true, ctx);
-                       } catch (Exception ex) {
+                       } catch (Exception) {
                                system.Host.WriteCompleted (streamName, false, ctx);
                                throw;
                        } finally {
@@ -381,10 +383,13 @@ namespace System.Configuration {
                {
                        SaveAs (filename, mode, false);
                }
-               
-               [MonoTODO ("Detect if file has changed")]
+
+               [MonoInternalNote ("Detect if file has changed")]
                public void SaveAs (string filename, ConfigurationSaveMode mode, bool forceUpdateAll)
                {
+                       string dir = Path.GetDirectoryName (Path.GetFullPath (filename));
+                       if (!Directory.Exists (dir))
+                               Directory.CreateDirectory (dir);
                        Save (new FileStream (filename, FileMode.OpenOrCreate, FileAccess.Write), mode, forceUpdateAll);
                }
 
@@ -438,9 +443,11 @@ namespace System.Configuration {
                        XmlTextReader reader = null;
                        Stream stream = null;
                        
+                       // FIXME: we should remove this kind of hack that
+                       // hides the actual error
                        try {
                                stream = system.Host.OpenStreamForRead (streamName);
-                       } catch (Exception e) {
+                       } catch (Exception) {
                                return false;
                        }