Skip to content

Instantly share code, notes, and snippets.

@messo
Forked from anonymous/form1.cs
Created July 6, 2010 11:59
Show Gist options
  • Select an option

  • Save messo/465290 to your computer and use it in GitHub Desktop.

Select an option

Save messo/465290 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
textBox1.Text=dlg.FileName;
}
Textreader tr = new StreamReader(dlg.FileName);
StringBuilder sb = new StringBuilder();
string line;
while ((line = tr.ReadLine()) != null) { sb.Append(line).Append("\n"); }
textBox2.Text = sb.ToString();
tr.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment