private void Random_Click(object sender, EventArgs e) { if (CheckChanged()) { currentExcuse = new Excuse(random, selectedFolder); UpdateForm(false); } }
public void OpenFile(string fileToOPen) { using (Stream input = File.OpenRead(fileToOPen)) { BinaryFormatter bf = new BinaryFormatter(); Excuse temporaryExcuse = (Excuse)bf.Deserialize(input); Description = temporaryExcuse.Description; Results = temporaryExcuse.Results; LastUsed = temporaryExcuse.LastUsed; } }
private void Random_Click(object sender, EventArgs e) { if (Directory.GetFiles(selectedFolder).Length == 0) { MessageBox.Show("There are no excuse ifles in the selected folder."); } else if (CheckChanged()) { currentExcuse = new Excuse(random, selectedFolder); UpdateForm(false); } }
private void open_Click(object sender, EventArgs e) { if (CheckChanged()) { openFileDialog1.InitialDirectory = selectedFolder; openFileDialog1.FileName = excuseTextBox.Text + ".excuse"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { currentExcuse = new Excuse(openFileDialog1.FileName); UpdateForm(false); } } }
public void OpenFile(string fileToOPen) { try { using (Stream input = File.OpenRead(fileToOPen)) { BinaryFormatter bf = new BinaryFormatter(); Excuse temporaryExcuse = (Excuse)bf.Deserialize(input); Description = temporaryExcuse.Description; Results = temporaryExcuse.Results; LastUsed = temporaryExcuse.LastUsed; } } catch (SerializationException) { MessageBox.Show("Unable to read " + fileToOPen); LastUsed = DateTime.Now; } }