Skip to content

Instantly share code, notes, and snippets.

@immengineer
Last active February 17, 2018 04:29
Show Gist options
  • Save immengineer/5873f97b7f2fb52272db4a498a951e85 to your computer and use it in GitHub Desktop.
Save immengineer/5873f97b7f2fb52272db4a498a951e85 to your computer and use it in GitHub Desktop.

Revisions

  1. immengineer revised this gist Feb 17, 2018. No changes.
  2. immengineer created this gist Feb 17, 2018.
    28 changes: 28 additions & 0 deletions Form1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    textBox1.Text = "";
    try
    {
    using (var mmf = MemoryMappedFile.OpenExisting("Test"))
    using (var stream = mmf.CreateViewStream())
    using (StreamReader sr = new StreamReader(stream))
    {
    while (!sr.EndOfStream)
    {
    textBox1.Text = sr.ReadLine();
    }
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }
    }