Advertisement
PareX

OpenFileDialog

May 19th, 2019
16,073
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. //MADE BY PAREX |PEOPLE GIVING U THIS LINK IS COPY RIGHT
  2. OpenFileDialog opendialogfile = new OpenFileDialog();
  3.             opendialogfile.Filter = "Lua File (*.lua)|*.lua|Text File (*.txt)|*.txt";
  4.             opendialogfile.FilterIndex = 2;
  5.             opendialogfile.RestoreDirectory = true;
  6.             if (opendialogfile.ShowDialog() != DialogResult.OK)
  7.                 return;
  8.             try
  9.             {
  10.                 fastColoredTextBox1.Text = "";
  11.                 System.IO.Stream stream;
  12.                 if ((stream = opendialogfile.OpenFile()) == null)
  13.                     return;
  14.                 using (stream)
  15.                     this.fastColoredTextBox1.Text = System.IO.File.ReadAllText(opendialogfile.FileName);
  16.             }
  17.             catch(Exception ex)
  18.             {
  19.                 int num = (int)MessageBox.Show("An unexpected error has occured", "OOF!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  20.  
  21.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement