HI! looking for a simple example of opening and reading in a loop a raw ascii file 1 character at a time in vb.net
Printable View
HI! looking for a simple example of opening and reading in a loop a raw ascii file 1 character at a time in vb.net
Use system.IO.streamreader class and call its Read method then convert the returned value to a char. Something like this:
Code:Using reader As New IO.StreamReader("file path here")
Dim ch As Char
While reader.Peek >= 0
ch = Chr(reader.Read())
'Do whatever you like with this char here
End While
End Using
Removed, stanav's example is more complete. :)
i was seeing suggestions that included:
fileope() and Lineinput()
are these suggestions wrong or are they a different way of doing the same thing?
I just did the two most essential lines from his example. He's actually looping through the output. I just did:
As I said, his example is much more complete.Code:Dim st As New IO.StreamReader("C:\MyASCIIFile.txt")
Convert.ToChar(st.Read())
They are VB6 legacy functions and since you're writing in .net language now, you should use .net classes/methods. On the other hand, if you just want to know what those methods do, Google it and you'll be flooded with results.
Yea, those aren't used anymore. There are far better ways to read text files. :)