BurningBunny

openFileDialog Mainform.cs

Mar 15th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.IO;
  5. using System.Windows.Forms;
  6.  
  7. namespace TestOpenFileDialog
  8. {
  9.     /// <summary>
  10.     /// Description of MainForm.
  11.     /// </summary>
  12.     public partial class MainForm : Form
  13.     {
  14.         public MainForm()
  15.         {
  16.             //
  17.             // The InitializeComponent() call is required for Windows Forms designer support.
  18.             //
  19.             InitializeComponent();
  20.            
  21.             //
  22.             // TODO: Add constructor code after the InitializeComponent() call.
  23.             //
  24.         }
  25.        
  26.         void Button1Click(object sender, EventArgs e)
  27.         {
  28.             DialogResult d = openFileDialog1.ShowDialog();
  29.             if (d == DialogResult.OK)
  30.             {
  31.                 string filename = openFileDialog1.FileName;
  32.                 FileStream f = new FileStream(filename, FileMode.Open);
  33.                 StreamReader sr = new StreamReader(f);
  34.                 //richTextBox1.Rtf = sr.ReadToEnd();
  35.                 sr.Close();            
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment