Advertisement
DiscordProgrammer404

OpenFileDialog

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