Fixed an error where loading config files from previous versions would crash the application.

This commit is contained in:
Michael Möller
2012-07-26 06:50:56 +00:00
parent 53a14ec30c
commit 992fa702dc
+4 -1
View File
@@ -99,6 +99,7 @@ namespace OpenHardwareMonitor.Hardware {
try {
byte[] array = Convert.FromBase64String(s);
s = null;
DateTime now = DateTime.UtcNow;
using (MemoryStream m = new MemoryStream(array))
using (GZipStream c = new GZipStream(m, CompressionMode.Decompress))
using (BinaryReader reader = new BinaryReader(c)) {
@@ -106,7 +107,9 @@ namespace OpenHardwareMonitor.Hardware {
long t = 0;
while (true) {
t += reader.ReadInt64();
DateTime time = DateTime.FromBinary(t);
DateTime time = DateTime.FromBinary(t);
if (time > now)
break;
float value = reader.ReadSingle();
AppendValue(value, time);
}