masj78
Active member
I am using a file as a data store. It will allow me to write one word or sentance but if I try to write more than one it gives me my error opening file. Code is as follows:
VB.NET:
Dim strStore As String
Dim fileName As New IO.StreamWriter(File.Open("C:\store.txt", IO.FileMode.Append))
-----------------------------------------------------------------------------------
Private Sub cmdStore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStore.Click
Try
strStore = storeText.Text Text from text box
fileName.WriteLine(System.Environment.NewLine)
fileName.WriteLine(strStore) write to stream
MsgBox(strStore & " has been stored!") message has stored
fileName.Flush() flush to file
fileName.Close() close file
fileName = Nothing
Catch ex As Exception
MsgBox("Error Opening File!") error that is showing on second store attempt
End Try
End Sub
Have a vague idea its something to do with opening and closing the file.
Any ideas of the solution anyone!
VB.NET:
Dim strStore As String
Dim fileName As New IO.StreamWriter(File.Open("C:\store.txt", IO.FileMode.Append))
-----------------------------------------------------------------------------------
Private Sub cmdStore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStore.Click
Try
strStore = storeText.Text Text from text box
fileName.WriteLine(System.Environment.NewLine)
fileName.WriteLine(strStore) write to stream
MsgBox(strStore & " has been stored!") message has stored
fileName.Flush() flush to file
fileName.Close() close file
fileName = Nothing
Catch ex As Exception
MsgBox("Error Opening File!") error that is showing on second store attempt
End Try
End Sub
Have a vague idea its something to do with opening and closing the file.
Any ideas of the solution anyone!