K
Keith G Hicks
I'm trying to read a text file and alter the contents of specific lines in
the file. I know how to use streamreader to read each line of a file. I'm
doing that already to get the data into a database. What I need help with is
on how to locate a specific line in the file, change it and then save the
updated text file. Can anyone help me out or point me to a site that
explains this clearly?
Here's part of my code that reads the contents of one of the lines into a
variable so I can post it to the db later on in the code.
Dim sr As StreamReader
sr = New StreamReader(textFilesLocation & sImportFolder & "\" &
sFileToImport)
Do
srLine = sr.ReadLine()
If InStr(srLine, "Publication Notice:", CompareMethod.Text) > 0 Then
If Len(srLine) >= 20 Then
ImportType = Trim(Mid(srLine, 20))
End If
End If
Loop Until InStr(srLine, "*** End Notice ***", CompareMethod.Text) <> 0
Thanks,
Keith
the file. I know how to use streamreader to read each line of a file. I'm
doing that already to get the data into a database. What I need help with is
on how to locate a specific line in the file, change it and then save the
updated text file. Can anyone help me out or point me to a site that
explains this clearly?
Here's part of my code that reads the contents of one of the lines into a
variable so I can post it to the db later on in the code.
Dim sr As StreamReader
sr = New StreamReader(textFilesLocation & sImportFolder & "\" &
sFileToImport)
Do
srLine = sr.ReadLine()
If InStr(srLine, "Publication Notice:", CompareMethod.Text) > 0 Then
If Len(srLine) >= 20 Then
ImportType = Trim(Mid(srLine, 20))
End If
End If
Loop Until InStr(srLine, "*** End Notice ***", CompareMethod.Text) <> 0
Thanks,
Keith