浏览代码

Re-create the settings file if it got deleted

Daniel Chalmers 2 年之前
父节点
当前提交
5a37822119
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      DesktopClock/MainWindow.xaml.cs

+ 5 - 0
DesktopClock/MainWindow.xaml.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Diagnostics;
 using System.Diagnostics;
+using System.IO;
 using System.Windows;
 using System.Windows;
 using System.Windows.Input;
 using System.Windows.Input;
 using DesktopClock.Properties;
 using DesktopClock.Properties;
@@ -60,6 +61,10 @@ public partial class MainWindow : Window
     {
     {
         Settings.Default.Save();
         Settings.Default.Save();
 
 
+        // Re-create the settings file if it got deleted.
+        if (!File.Exists(Settings.Path))
+            Settings.Default.Save();
+
         // Open settings file in notepad.
         // Open settings file in notepad.
         Process.Start("notepad", Settings.Path);
         Process.Start("notepad", Settings.Path);
     }
     }