From 2d98fb99be8d46f292af9cc268dc0d3f0cd1f8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= Date: Sun, 11 Nov 2018 12:44:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D1=8B=D1=81=D1=82=D1=80=D0=BE=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D1=81=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BD=D0=B5=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=D1=81=D1=8C=20(=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82?= =?UTF-8?q?=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=B8=D0=BB=D0=B8=20=D0=BF=D0=BE=D0=B2=D1=80=D0=B5?= =?UTF-8?q?=D0=B6=D0=B4=D0=B5=D0=BD=D0=BD=D0=BE=D0=BC=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Signal Generator/Settings.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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; } } }