using System.Runtime.Serialization.Formatters.Binary;
namespace WindowsFormsApp2
public string Name { get; set; }
public string Text { get; set; }
public partial class Form1 : Form
private void button1_Click(object sender, EventArgs e)
if (saveFileDialog1.ShowDialog() != DialogResult.OK) return;
string path = saveFileDialog1.FileName;
using (var fs = File.OpenWrite(path))
var bf = new BinaryFormatter();
bf.Serialize(fs, newNote);
private void button2_Click(object sender, EventArgs e)
if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
string path = openFileDialog1.FileName;
using (var fs = File.OpenRead(path))
var bf = new BinaryFormatter();
var note = bf.Deserialize(fs) as Note;
textBox1.Text = note.Name;
textBox2.Text = note.Text;