public void SerializeObject(string filename, ObjectToSerialize objectToSerialize) { Stream stream = File.Open(filename, FileMode.Create); BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, objectToSerialize); stream.Close(); }
private void recordStopButton_Click(object sender, EventArgs e) { ObjectToSerialize ots = new ObjectToSerialize(); ots.Events = events; string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\test"; ConvertEvent(events); SerializeObject(filePath, ots); keyboardHook.Stop(); mouseHook.Stop(); }
private void button1_Click(object sender, EventArgs e) { try { isCancel = false; string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\test"; ObjectToSerialize ots = DeSerializeObject(filePath); events = ots.Events; Thread thread = new Thread(() => WorkThreadFunction(int.Parse(txtLoop.Text))); thread.Start(); }catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void recordStopButton_Click(object sender, EventArgs e) { ObjectToSerialize ots = new ObjectToSerialize(); ots.Events = events; //string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\test"; string filePath = Environment.CurrentDirectory + "\\data\\" + DateTime.Now.ToString("ddMMyyyy-HHmmss"); ConvertEvent(events); SerializeObject(filePath, ots); keyboardHook.Stop(); mouseHook.Stop(); }
private void button1_Click(object sender, EventArgs e) { try { string filePath = null; OpenFileDialog theDialog = new OpenFileDialog(); theDialog.Title = "Open Data File"; theDialog.InitialDirectory = Environment.CurrentDirectory; if (theDialog.ShowDialog() == DialogResult.OK) { filePath = theDialog.FileName.ToString(); } isCancel = false; ObjectToSerialize ots = DeSerializeObject(filePath); events = ots.Events; Thread thread = new Thread(() => WorkThreadFunction(int.Parse(txtLoop.Text))); thread.Start(); }catch (Exception ex) { MessageBox.Show(ex.Message); } }