void SaveUIConfig() { using (FileStream fs = new FileStream("UI.dat", FileMode.Create)) { WindowStat stat = new WindowStat { opacity = opacity, secondColumnWidth = secondColumnWidth, Left = Left, Top = Top }; BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, stat); } }
void LoadUIConfig() { try { using (FileStream fs = new FileStream("UI.dat", FileMode.Open)) { BinaryFormatter bf = new BinaryFormatter(); WindowStat stat = bf.Deserialize(fs) as WindowStat; opacity = stat.opacity; secondColumnWidth = stat.secondColumnWidth; WindowStartupLocation = WindowStartupLocation.Manual; Left = stat.Left; Top = stat.Top; } } catch (FileNotFoundException e) { } catch (SerializationException e) { } }