I need to edit the text in many files so I'm writing a small routine to do
this.
First I have a method that loops through all the files in a directory and
passes the full file path to another method (ReadFile).
I'm going to use this to edit the file paths in all of my WMP play lists.
When I run this the string variable is not being changed using the replace
method. Here's what I have:
Private Sub ReadFile(ByVal path As String)
Try
Dim sr As StreamReader = New StreamReader(pa th)
Dim line As String
Dim sFind As String = "F:\Music"
Dim sReplace As String = "G:\Music"
Do
line = sr.ReadLine()
Debug.Print(lin e)
line.Replace(sF ind, sReplace)
'text was not replaced
Debug.Print(lin e)
Loop Until line Is Nothing
sr.Close()
Catch ex As Exception
ErrLog(ex)
End Try
End Sub
What would you recomend for a good way to update and save the file with the
new text?
Thanks.
--
moondaddy@noema il.noemail
this.
First I have a method that loops through all the files in a directory and
passes the full file path to another method (ReadFile).
I'm going to use this to edit the file paths in all of my WMP play lists.
When I run this the string variable is not being changed using the replace
method. Here's what I have:
Private Sub ReadFile(ByVal path As String)
Try
Dim sr As StreamReader = New StreamReader(pa th)
Dim line As String
Dim sFind As String = "F:\Music"
Dim sReplace As String = "G:\Music"
Do
line = sr.ReadLine()
Debug.Print(lin e)
line.Replace(sF ind, sReplace)
'text was not replaced
Debug.Print(lin e)
Loop Until line Is Nothing
sr.Close()
Catch ex As Exception
ErrLog(ex)
End Try
End Sub
What would you recomend for a good way to update and save the file with the
new text?
Thanks.
--
moondaddy@noema il.noemail
Comment