Created
January 2, 2014 08:39
-
-
Save riston/8216462 to your computer and use it in GitHub Desktop.
Visual Basic, reading all text to string from file and writing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports | |
Imports System.IO | |
Imports System.Text | |
Public Class MainForm | |
Private filePath = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\settings.txt" | |
Private Sub Chart1_Click(sender As Object, e As EventArgs) | |
End Sub | |
Private Sub MainForm_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed | |
End Sub | |
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load | |
If File.Exists(filePath) Then | |
'File exists open file and set the settings | |
MessageBox.Show(File.ReadAllText(filePath)) | |
End If | |
End Sub | |
Imports | |
Imports System.IO | |
Imports System.Text | |
Public Class MainForm | |
Private filePath = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\settings.txt" | |
Private Sub Chart1_Click(sender As Object, e As EventArgs) | |
End Sub | |
Private Sub MainForm_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed | |
End Sub | |
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load | |
If File.Exists(filePath) Then | |
'File exists open file and set the settings | |
MessageBox.Show(File.ReadAllText(filePath)) | |
End If | |
End Sub | |
Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing | |
Dim settingsString As String = "FirstSecondnThirdn" | |
File.WriteAllText(filePath, settingsString) | |
MessageBox.Show("Are you really closing?") | |
End Sub | |
End Class | |
Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing | |
Dim settingsString As String = "FirstSecondnThirdn" | |
File.WriteAllText(filePath, settingsString) | |
MessageBox.Show("Are you really closing?") | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment