I want it to check for a text file, if it doesnt exist, create it and then write a line to it, if it does exist open it and write a line.
Printable View
I want it to check for a text file, if it doesnt exist, create it and then write a line to it, if it does exist open it and write a line.
Try this now :Quote:
Originally posted by Synth3t1c
I want it to check for a text file, if it doesnt exist, create it and then write a line to it, if it does exist open it and write a line.
VB Code:
Private Sub FileOperation(ByVal Pth As String) Dim writr As StreamWriter If File.Exists(Pth) Then writr = New StreamWriter(Pth) writr.WriteLine("File was there, and New Value was added") MessageBox.Show("done") Else writr = New StreamWriter(Pth) writr.WriteLine("File wasn't there, and New value was added") MessageBox.Show("done") End If writr.Close() End Sub
it overwrites whats in the file...
In the first 'IF' case change this line :Quote:
Originally posted by Synth3t1c
it overwrites whats in the file...
toVB Code:
writr = New StreamWriter(Pth)
.VB Code:
writr = New StreamWriter(Pth, True)