2007-11-14 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.Configuration / System.Configuration / Configuration.cs
index 74271acfa6d264555ebe486ad116cfe8e9ceb31f..9f6a3ae117511a6d8f2c1030543d4a3fb9d25616 100644 (file)
@@ -366,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 {
@@ -382,11 +382,14 @@ namespace System.Configuration {
                public void SaveAs (string filename, ConfigurationSaveMode mode)
                {
                        SaveAs (filename, mode, false);
-               }\r
-\r
+               }
+
                [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);
                }
 
@@ -440,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;
                        }