Sunday, February 7, 2010

Replace any Character in Text File in Vb.net

Sub Main()
Dim Fs As FileStream = New FileStream("c:\Edit1.TXT",FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
Dim sw As New StreamWriter(Fs)
Dim sr As New StreamReader(Fs)
Dim str As String
str = sr.ReadToEnd()
str = str.Replace(vbCrLf, "^")
Fs.Position = 0
Fs.SetLength(str.Length)
sw.Write(str)
sw.Flush()
sw.Close()
Fs.Close()
End Sub

Happy Coding!

No comments:

Post a Comment