Asking for support with locate and delete from text file.
Looking for unique term 'END' in file - want to delete the term as I will append text later in the routine and append a the same unique term 'END' later in the same routine.
Here another poster's (Thanks PsychoCoder) code to find the term:
Dim file As System.IO.File
Dim reader as System.IO.StreamReader
Dim line As String
reader = file.OpenText("c:\mydoc.txt")
'now loop through each line
While reader.Peek <> -1
line = reader.ReadLine()
Now check for your specific word
If line.Contains("END") Then
'Do your work here
MSGBOX("SUCCESS")
'How do I delete -> line
Else
'Do something else here
MSGBOX("TRY AGAIN")
End If
End While
'close your reader
reader.Close()
I found that you can't convert easily a SteamWriter to String - which is how I thought this method SHOULD work.
The goal is to STRIP the line containing "END" - not replace it with a space and allow the routine to continue.
Please help?
Thanks!
~M

New Topic/Question
Reply



MultiQuote





|