You may find your file has EOF characters within it, causing the stream to end.
On 5 Sep, 20:54, rbdavidson <[EMAIL PROTECTED]> wrote: > Your problem is probably encoding related, also you may want to use > BinaryReader which is more tolerant of odd-ball data. > > On a side note, dropping into a textBox may not work the way you > expect. TextBox.Text does not behave the same as a String variable or > an array of characters or bytes. TextBox.Text often truncates data > when it runs into characters it can't display, Strings etc... don't. > It may be that your garbage characters are causing the TextBox.Text > property to truncate your data string. i.e. Your code may be fine but > you simply can't display it all in a textbox. > > On Sep 3, 12:23 pm, Andrew <[EMAIL PROTECTED]> wrote: > > > > > Hi all, I am trying to read a text like file that is padded with some > > garbage (or at least it is to me). When I try to read using > > StreamReader it does not make it past the first few awkward > > characters, can anyone suggest a method to read in this data? Simply > > ignoring it is a acceptable solution, as the end result is to filter > > this out. > > > This is an example of what the input is like, everything before the > > 0H## is garbage, but using StreamReader it does not get past them. > > > µ á 0H12$HEHDT,224.71,T*1D > > É á 0H14$WIMWV,009,R,023,N,A*2B > > É á 0H15$VMVLW,301074.5,N,0296833,N*79 > > Ý á 0H23$AGHTD,V,3.9,R,R,N,10,10,0.5,10.0,,0.0,,T,A,A,A,224.7*6C > > Ý á 0H12$HCHDM,232.90,M*13 > > > Here is the implementation of the code. Currently just dumps what is > > read into a text box as proof of concept. > > > myStream = opnFile.OpenFile() > > If (myStream IsNot Nothing) Then > > Dim objReader As New > > StreamReader(opnFile.FileName) > > txtOut.Text = objReader.ReadToEnd > > objReader.Close() > > 'Read stream > > End If > > > Any help greatly appreciated. > > > Cheers and thanks.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://cm.megasolutions.net/forums/default.aspx -~----------~----~----~----~------~----~------~--~---
