![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Read Byte Array into String for Delimiting? I have a byte[] that came from a network resource. I would like to read this "line by line" and split it on tab character. The bytes are ASCII encoded, so there should be real EOL markers. I have my MemoryStream on the bytes, now how can I quickly read it? I can't use LINQ because I am working strictly with an instance Type. Thanks. .NET 3.5. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Read Byte Array into String for Delimiting? Use Encoding.ASCII.GetString () on the byte [] or open a StreamReader or a TextReader on your MemoryStream.. /LM "coconet" <coconet@xxxxxx> wrote in message news:1dce34dj47g7l3mhnksaiomromqafl8cd0@xxxxxx Quote: > > I have a byte[] that came from a network resource. I would like to > read this "line by line" and split it on tab character. The bytes are > ASCII encoded, so there should be real EOL markers. I have my > MemoryStream on the bytes, now how can I quickly read it? > > I can't use LINQ because I am working strictly with an instance Type. > > Thanks. .NET 3.5. > > > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Read Byte Array into String for Delimiting? The initial byte[] is huge, so I'd rather not turn it into a single giant string with GetString(). I think what I want to do is read the byte[] until I hit Environment.NewLine, then re-read the byte[] into a tempbyte[] with an offset from n to n+read. Then I can to GetString() on that piece. But I don't know how to code that. I want to use Read or ReadBytes, maybe BeginRead() to make it Async so I can report what I'm working on. But I don't know how the code could look. Help with any guidance code? Thanks. On Sat, 24 May 2008 05:03:08 +0200, "Luc E. Mistiaen" <luc.mistiaen@xxxxxx> wrote: Quote: >Use Encoding.ASCII.GetString () on the byte [] or open a StreamReader or a >TextReader on your MemoryStream.. > >/LM > >"coconet" <coconet@xxxxxx> wrote in message >news:1dce34dj47g7l3mhnksaiomromqafl8cd0@xxxxxx Quote: >> >> I have a byte[] that came from a network resource. I would like to >> read this "line by line" and split it on tab character. The bytes are >> ASCII encoded, so there should be real EOL markers. I have my >> MemoryStream on the bytes, now how can I quickly read it? >> >> I can't use LINQ because I am working strictly with an instance Type. >> >> Thanks. .NET 3.5. >> >> >> >> |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Read Byte Array into String for Delimiting? coconet <coconet@xxxxxx> wrote: Quote: > The initial byte[] is huge, so I'd rather not turn it into a single > giant string with GetString(). I think what I want to do is read the > byte[] until I hit Environment.NewLine, then re-read the byte[] into a > tempbyte[] with an offset from n to n+read. Then I can to GetString() > on that piece. But I don't know how to code that. I want to use Read > or ReadBytes, maybe BeginRead() to make it Async so I can report what > I'm working on. But I don't know how the code could look. (plus a bit for buffering). -- Jon Skeet - <skeet@xxxxxx> Web site: http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet C# in Depth: http://csharpindepth.com |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Convert Byte() to string | VB Script | |||
| Fast byte array comparison for ordering purposes | .NET General | |||
| creating a byte array to read in image | PowerShell | |||
| Creating a byte array | PowerShell | |||
| String to Array | PowerShell | |||