Share via

Text File Load with VB.Net and Rich TextBox

~OSD~ 2,201 Reputation points
Feb 10, 2021, 10:06 PM

Hi,

I have text file which looks like as follows:
66549-image.png

Now I used Rich Text Box to display the contents of this text file on VB form as:

RichTextBox1.LoadFile("D:\Backup\AppList.txt", RichTextBoxStreamType.PlainText)  

I have noticed two strange characters (ÿþ) appended as:
66696-image.png

or sometimes on top as:
66684-image.png

Any thoughts why this strange characters appeared and how to get rid of them?

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,822 questions
{count} votes

Accepted answer
  1. Viorel 121.3K Reputation points
    Feb 11, 2021, 6:29 AM

    Try an alternative:

    RichTextBox1.Text = File.ReadAllText("D:\Backup\AppList.txt")
    

    Or change the encoding of AppList.txt, if possible. Use “UTF-8 with signature” encoding.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.