public bool Saver() { try { Stream StreamWrite; SaveFileDialog DialogueSauver = new SaveFileDialog(); DialogueSauver.DefaultExt = "shape"; DialogueSauver.Title = "Save as shape"; DialogueSauver.Filter = "shape files (*.shape)|*.shape|All files (*.*)|*.*"; if (DialogueSauver.ShowDialog() == DialogResult.OK) { if ((StreamWrite = DialogueSauver.OpenFile()) != null) { BinaryFormatter BinaryWrite = new BinaryFormatter(); BinaryWrite.Serialize(StreamWrite, this.s); StreamWrite.Close(); return(true); } } } catch (Exception e) { MessageBox.Show("Exception:" + e.ToString(), "Save error:"); } return(false); }
public bool SaveSelected() { ArrayList a = this.s.getSelectedList(); if ((a != null) && (a.Count > 0)) { try { Stream StreamWrite; SaveFileDialog DialogueSauver = new SaveFileDialog(); DialogueSauver.DefaultExt = "sobj"; DialogueSauver.Title = "Save as sobj"; DialogueSauver.Filter = "sobj files (*.sobj)|*.sobj|All files (*.*)|*.*"; if (DialogueSauver.ShowDialog() == DialogResult.OK) { if ((StreamWrite = DialogueSauver.OpenFile()) != null) { BinaryFormatter BinaryWrite = new BinaryFormatter(); BinaryWrite.Serialize(StreamWrite, a); StreamWrite.Close(); return(true); } } } catch (Exception e) { MessageBox.Show("Exception:" + e.ToString(), "Save error:"); } } return(false); }
public static void Store(Employee employee) { FileStream stream = new FileStream(employee.FirstName + employee.LastName + ".txt", FileMode.Create); StreamWrite writer = new StreamWrite(stream); writer.WriteLine(employee.FirstName); writer.WriteLine(employee.LastName); writer.WriteLine(employee.Salary); writer.Close(); }