public void SaveToFile(String fileName, CircuitBoard cb) { this.flowNets.Add(cb); FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); BinaryFormatter bf = new BinaryFormatter(); try { foreach (CircuitBoard fl in flowNets) { bf.Serialize(fs, fl); } } catch (SerializationException ex) { MessageBox.Show(ex.Message); } catch (IOException ex) { MessageBox.Show(ex.Message); } finally { if (fs != null) { fs.Close(); } } }
private void loadToolStripMenuItem_Click(object sender, EventArgs e) { sl = new SavingAndLoading(); OpenFileDialog open = new OpenFileDialog(); open.Filter = "Text|*.txt|All|*.*"; if (open.ShowDialog() == DialogResult.OK) { sl.LoadFile(open.FileName); cb = sl.flowNets.First(); this.Refresh(); } }
public Form1() { InitializeComponent(); cb = new CircuitBoard(); lblSelected.Visible = false; }