I have a simple text file created with notepad and I am trying to load it into a textbox with this code:
VB Code:
If ofd.ShowDialog = DialogResult.OK Then If File.Exists(ofd.FileName) Then Dim sr As StreamReader = New StreamReader(ofd.FileName) Try txtOriginal.Text = sr.ReadToEnd Catch ex As Exception MessageBox.Show("Could not load that file: " & ex.Message, "Censor", MessageBoxButtons.OK) Finally 'tidy up a bit txtOriginal.SelectionLength = 0 sr.Close() End Try End If End If
My file has some "£" (British Pounds Sterling symbol, (Shift + 3) on most keyboards.
The whole file loads ok except for the sterling signs. What gives? If I go out of my way to make it work, save the file in unicode, and try again it works OK, but not all of my files will be in unicode).
I'm pretty sure it should show EVERY single printable char in the file (regardless of its encoding), in the textbox, yet this is not the case.




Reply With Quote