1
Reply

Reading file text "as is"

pseudobill2004

pseudobill2004

Jan 19 2005 1:37 PM
2.1k
I'm reading text from a file with the following code: System.IO.FileStream oReadStream = new System.IO.FileStream(sFile, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.StreamReader oReader = new System.IO.StreamReader(oReadStream, System.Text.Encoding.ASCII); this.txtMyTextbox.Text = oReader.ReadToEnd(); The problem is that special character strings such as: "x²" or "90°" are read as "x?" and "90?". If I change System.Text.Encoding.ASCII to System.Text.Encoding.UTF7 these two get read correctly, but other standard xml strings don't. Is there a way to read the file contents exactly as is? i.e., the same as if I copied the file contents via the clipboard directly into the textbox? (this works fine)

Answers (1)