Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am trying to replace a line using the following code
VB
Dim reader As New StreamReader(strFile)
Dim line As String = reader.ReadLine
   While line <> ""

      line = reader.ReadLine
      If line <> "" Then
         Dim values() As String = line.Split(":")
          If values(0) = "GBPtoUSD" Then
             strFile.Replace(line, "GBPtoUSD:" + txtGBPtoUSD.Text)
          End If
 
      End If

    End While
reader.Close()


I am trying to replace the line using
VB
strFile.Replace(line, "GBPtoUSD:" + txtGBPtoUSD.Text)


but it doesnt seem to work.
Please advise.

Thanks
Shailaja
Posted
Updated 21-Oct-13 4:16am
v2

1 solution

Do somethign along the lines:

1. ReadAllLines[^] into an arrya.
2. Fiddle with the array, replace, remove etc.
3. WriteAllLines [^]to a new file.

Click on the links in the documentation to see the examples.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Oct-13 11:25am    
Fair enough, a 5.
—SA
Kenneth Haugland 21-Oct-13 11:31am    
Thanks Sergey :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900