diff --git a/Signal Generator/Settings.cs b/Signal Generator/Settings.cs index 760ce1b..3a3bfc7 100644 --- a/Signal Generator/Settings.cs +++ b/Signal Generator/Settings.cs @@ -1,4 +1,5 @@ -using System.Collections.ObjectModel; +using System; +using System.Collections.ObjectModel; using System.IO; using System.Runtime.Serialization.Formatters.Binary; @@ -41,10 +42,15 @@ namespace Signal_Generator.Properties { public static ObservableCollection LoadSignals() { BinaryFormatter formatter = new BinaryFormatter(); - using (FileStream fs = new FileStream("settings.dat", FileMode.Open)) + try { - if (!fs.CanRead) return null; - return (ObservableCollection)formatter.Deserialize(fs); + using (FileStream fs = new FileStream("settings.dat", FileMode.Open)) + { + return (ObservableCollection)formatter.Deserialize(fs); + } + } catch + { + return null; } } }