|
-
Jul 12th, 2004, 12:07 AM
#1
Thread Starter
Lively Member
Text file (simple) [resolve]
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.
Last edited by Synth3t1c; Jul 20th, 2004 at 07:15 PM.
-
Jul 12th, 2004, 12:36 AM
#2
Sleep mode
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.
Try this now :
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
-
Jul 20th, 2004, 06:26 PM
#3
Thread Starter
Lively Member
it overwrites whats in the file...
-
Jul 20th, 2004, 06:32 PM
#4
Sleep mode
Originally posted by Synth3t1c
it overwrites whats in the file...
In the first 'IF' case change this line :
VB Code:
writr = New StreamWriter(Pth)
to
VB Code:
writr = New StreamWriter(Pth, True)
.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|