|
-
Apr 9th, 2006, 07:04 AM
#1
[RESOLVED] [2005] Problem reading textfile
Hello!
Im reading a textfile using this code:
VB Code:
Dim sReader As New IO.StreamReader(New IO.FileStream(Application.StartupPath & "\data\" & drink & ".txt", IO.FileMode.Open))
While Not sReader.Peek
TextBox1.AppendText(sReader.ReadToEnd)
End While
But my problem is that it doesnt read "special characters" like åäö.
so if my textfile would contain "Hellö" then all that I would get would be "Hell"
Can this be fixed?
-
Apr 9th, 2006, 07:45 AM
#2
Frenzied Member
Re: [2005] Problem reading textfile
u could try reading all the bytes in the file and converting to characters.
streamreader tends to stop on special characters.
-
Apr 9th, 2006, 08:45 AM
#3
Re: [2005] Problem reading textfile
Worked fine for me, the below code was used to test, and the special characters displayed in the messagebox...
VB Code:
Dim MyWriter As New System.IO.StreamWriter("c:\test.txt", False)
MyWriter.WriteLine("Hellö There")
MyWriter.WriteLine("This ö is a test")
MyWriter.Close()
Dim MyReader As New System.IO.StreamReader("c:\test.txt")
While MyReader.Peek <> -1
MessageBox.Show(MyReader.ReadLine)
End While
MyReader.Close()
Maybe its perhaps the filestream you declared that is doing it?
***EDIT - I actually tested it with the filestream you used on the streamreader, and it still worked fine.
Are you trying to display this in a control that may not display those characters correctly?
-
Apr 9th, 2006, 10:29 AM
#4
Re: [2005] Problem reading textfile
thanks for the replies.
Gigemboy:
Im just displaying the text in an ordinary textbox.
I tried using your read code but it gives me the same results...
High6 could you help me with that? Coz I dont have a clue how id to that.
Thanks guys
-
Apr 9th, 2006, 01:25 PM
#5
Re: [2005] Problem reading textfile
....
...I dont know what happened, but suddenly it displays special characters without any problem..
-
May 3rd, 2006, 07:39 AM
#6
Addicted Member
Re: [RESOLVED] [2005] Problem reading textfile
Dim reader As IO.StreamReader = New IO.StreamReader(Application.StartupPath.ToString() + "\languages.dat", System.Text.Encoding.Default)
Now your Streamreader can read Öë
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|