If you are not changing the length of the line, you might be better of by just replacing the relevant bytes in the file. But in most cases you need to change the length of the line and therefore move the bytes for the rest of the file on the disk. The easiest way to do that is to read the entire file into an array, manipulate the array and write it to the file agian:
-----------------------------------------------
Private Function ChangeLine(ByVal FileName As String, ByVal LineNo As Int32, ByVal NewValue As String) As Boolean
Dim SR As New IO.StreamReader(FileName)
Dim FileArr() As String = Split(SR.ReadToEnd, vbCrLf)
SR.Close()
If UBound(FileArr) >= LineNo Then
FileArr(LineNo) = NewValue
ChangeLine = True
Dim SW As New IO.StreamWriter(FileName)
SW.Write(Join(FileArr, vbCrLf))
SW.Close()
Else
ChangeLine = False
End If
----------------------------------------------
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.