Legend_Dev

Open file function

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