private void onImportMenuItemClick(object sender, System.EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "CP3 Network Capture (*.cnc)|*.cnc"; if (ofd.ShowDialog() == DialogResult.OK) { this.m_Playback = new NetworkPlayback(ofd.FileName); this.updateModeMenu(); this.updateUI(true); } }
private void onOpenMenuItemClick(object sender, System.EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Classroom Playback Files (*.cpf)|*.cpf"; if (ofd.ShowDialog() == DialogResult.OK) { BinaryFormatter bf = new BinaryFormatter(); FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read); try { this.m_Playback = (NetworkPlayback)bf.Deserialize(fs); } catch (Exception) { MessageBox.Show("Error: File format is outdated, corrupted or invalid", "Classroom Playback", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } finally { fs.Flush(); fs.Close(); } this.updateModeMenu(); this.updateUI(true); } }