Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button_LoadSource_Click(object sender, EventArgs e)
- {
- Stream myStream = null;
- OpenFileDialog openFileDialog1 = new OpenFileDialog();
- openFileDialog1.InitialDirectory = "c:\\";
- openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
- openFileDialog1.FilterIndex = 2;
- openFileDialog1.RestoreDirectory = true;
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- try
- {
- if ((myStream = openFileDialog1.OpenFile()) != null)
- {
- using (myStream)
- {
- textbox1.Text = File.ReadAllText(openFileDialog1.FileName);
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement