Hello,
I have a text file with a character (hex 1A) that I would like to remove. I'm having troubles writing a script to do this. I'm new to VB and any help would be greatly appreciated.
Thanks!
Printable View
Hello,
I have a text file with a character (hex 1A) that I would like to remove. I'm having troubles writing a script to do this. I'm new to VB and any help would be greatly appreciated.
Thanks!
Something like the following will remove all 0x1A characters from the file.
VB.NET Code:
Using f As FileStream = File.OpenRead("path\file") Using sr As New StreamReader(f) Dim text As String = sr.ReadToEnd() text = text.Replace(CChar(&H1A), String.Empty) End Using End Using
Thank you very much!
Sorry, I forgot all about actually writing to the file. :blush:
Here's some more sensible code.
VB.NET Code:
Dim text As String Using sr As New StreamReader("path\to\file") text = sr.ReadToEnd() text = text.Replace(CChar(&H1A).ToString(), String.Empty) End Using Using sw As New StreamWriter("path\to\file") sw.Write(text) End Using