Results 1 to 4 of 4

Thread: [2005] Remove hex 1A character from txt file??

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    [2005] Remove hex 1A character from txt file??

    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!

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] Remove hex 1A character from txt file??

    Something like the following will remove all 0x1A characters from the file.

    VB.NET Code:
    1. Using f As FileStream = File.OpenRead("path\file")
    2.   Using sr As New StreamReader(f)
    3.     Dim text As String = sr.ReadToEnd()
    4.     text = text.Replace(CChar(&H1A), String.Empty)
    5.   End Using
    6. End Using

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: [2005] Remove hex 1A character from txt file??

    Thank you very much!

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] Remove hex 1A character from txt file??

    Sorry, I forgot all about actually writing to the file.
    Here's some more sensible code.

    VB.NET Code:
    1. Dim text As String
    2.  
    3. Using sr As New StreamReader("path\to\file")
    4.   text = sr.ReadToEnd()
    5.   text = text.Replace(CChar(&H1A).ToString(), String.Empty)
    6. End Using
    7.  
    8. Using sw As New StreamWriter("path\to\file")
    9.   sw.Write(text)
    10. End Using

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width