// Serialize and Save all Template list private void SerializeAndSave(string fileName, Template templejt) { System.IO.Stream stream = System.IO.File.Open(fileName, System.IO.FileMode.Truncate); BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, templejt); stream.Close(); }
private Template DeserializeAndLoad(string filename) { Template templejt = new Template(); System.IO.Stream stream = System.IO.File.Open(filename, System.IO.FileMode.Open); BinaryFormatter bFormatter = new BinaryFormatter(); if (stream.Length != 0) templejt = (Template)bFormatter.Deserialize(stream); stream.Close(); return templejt; }
private void button1_Click(object sender, EventArgs e) { if (!textBox2.Text.Equals("") && !textBox3.Text.Equals("")) { Template doZapisu = new Template(textBox3.Text); doZapisu.Name = textBox2.Text; doZapisu.UsageFrequency = 0; Templates.Add(doZapisu); UpdateTemplateList(); } }