kshadow22

Open / Save File Dialogs

Nov 3rd, 2015
144
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. "Text files (*.txt)|*.txt|All files (*.*)|*.*"
  3.  
  4.  
  5. Save Button:
  6. Dim SaveFile As New SaveFileDialog
  7. SaveFile.FileName = ""
  8. SaveFile.Filter = "Text Files (*.txt)|*.txt"
  9. SaveFile.Title = "Save"
  10. SaveFile.ShowDialog()
  11. Try
  12. Dim Write As New System.IO.StreamWriter(SaveFile.FileName)
  13. Write.Write(RichTextBox1.Text)
  14. Write.Close()
  15. Catch ex As Exception
  16.  
  17. End Try
  18.  
  19.  
  20.  
  21. Open Button:
  22. Dim OpenFile As New OpenFileDialog
  23. OpenFile.FileName = ""
  24. OpenFile.Filter = "Text Files (*.txt)|*.txt"
  25. OpenFile.Title = "Open"
  26. OpenFile.ShowDialog()
  27. Try
  28. Dim Read As New System.IO.StreamReader(OpenFile.FileName)
  29. RichTextBox1.Text = Read.ReadToEnd
  30. Read.Close()
  31. Catch ex As Exception
  32.  
  33. End Try
RAW Paste Data