Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7750121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:12:35+00:00 2026-06-01T11:12:35+00:00

I want to open text files and load them into a RichTextBox. This has

  • 0

I want to open text files and load them into a RichTextBox. This has been going fine so far, but now I’m struggling with an encoding issue.

So I used the GetType() method from this StackOverflow page:
How to find out the Encoding of a File? C#
– and it returns “System.Text.UnicodeEncoding”.

My questions now are:

  • How do I convert Unicode (I guess that’s what they are, although I haven’t double checked) into UTF8 (and possibly backwards)?
  • Can I switch the RichTextBox to display Unicode correctly? The following shows awkward results: rtb.LoadFile(aFile, RichTextBoxStreamType.PlainText);
  • How can I define which encoding a SaveFileDialog should use?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:12:36+00:00Added an answer on June 1, 2026 at 11:12 am

    Instead of having the RichTextBox load the file from the disk, load it yourself, while specifying the correct encoding. (By the way, Encoding.Unicode is just a synonym for “UTF-16 little-endian“.)

    string myText = File.ReadAllText(myFilePath, Encoding.Unicode);
    

    This will take care of the conversion for you. The string you get is encoded “correctly” (i.e. in the format used internally by .NET), so you can just assign it to the Text property of your RichTextBox.


    About your third question: The SaveFileDialog is just a tool that lets the user choose a file name. What you do with the file name (like: save some text into it, or encode some string and then save it) has nothing to do with the SaveFileDialog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why doesn't this code want to load all the values from a text file?
I want to make the descriptive text around a form link also open the
I want to open word, Power point and excel files in browser like PDF
This loads a set of values from an XML file and places them into
I have a few multimillion lined text files located in a directory, I want
I'm trying to load lines of a text file containing dictionary words into an
want to open a large text file and then search the content of it.
I want to save text from a textbox to the internalStorage and load it
I want open a path to vim from Screen's copy-mode by Ctrl-A f similarly
I want to open a webpage in internet explorer and navigate to a page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.