Ok, I decided to play with fire and read from my binary reader from 0 to <
content length. I figured I was playing with fire here "blindly" reading
from the stream with out really knowing if there was usable data there....
BUT! It worked! I'm finally getting my data! So I"m guessing that peekchar
really doesn't work the way I think it does? Anyone out there know why my
previous method was failing? I"m really curiose here!
Carlo
Jon Skeet [C# MVP] - 02 Sep 2004 07:30 GMT
> Ok, I decided to play with fire and read from my binary reader from 0 to <
> content length. I figured I was playing with fire here "blindly" reading
> from the stream with out really knowing if there was usable data there....
> BUT! It worked! I'm finally getting my data! So I"m guessing that peekchar
> really doesn't work the way I think it does? Anyone out there know why my
> previous method was failing? I"m really curiose here!
The problem is that PeekChar is trying to read a *character* (in this
case in the UTF-8 encoding) when the data isn't character data to start
with.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Carlo Razzeto - 07 Sep 2004 03:42 GMT
> The problem is that PeekChar is trying to read a *character* (in this
> case in the UTF-8 encoding) when the data isn't character data to start
> with.
Yeah, that seems to make sence now that I think about it, thanks!
Carlo
> Hello, I'm having trouble properly reading and decoding binary files (eg MS
> Word Doc, Adobe PDF) from a stream created from a Web Response. I have an
[quoted text clipped - 6 lines]
> string strSrcURI = this.strRootURI + '/' + this.UserName + '/' +
> this.MailBox + '/' + this.messageName + '/' + this.attachments[i];
<snip>
I don't see why you're using a BinaryReader at all. Why not just read
from the stream until it's exhausted, as if you were reading a file?
See http://www.pobox.com/~skeet/csharp/readbinary.html for some sample
code to completely read a stream and return a byte array with the
contents.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Carlo Razzeto - 07 Sep 2004 03:41 GMT
<snip>
> I don't see why you're using a BinaryReader at all. Why not just read
> from the stream until it's exhausted, as if you were reading a file?
>
> See http://www.pobox.com/~skeet/csharp/readbinary.html for some sample
> code to completely read a stream and return a byte array with the
> contents.
I wanted to ensure that I was reading that data in correctly, as Strings and
Chars in .Net seem to murder binaries, which I guess is because they are
nativly Unicode and not ASCII. I wasn't aware it was possible to do this
with the simple stream reader, I thought it just translated everything to a
native .Net string/char. Anyway, thanks for all the information, it was very
informative.
Carlo
Jon Skeet [C# MVP] - 07 Sep 2004 06:46 GMT
> > I don't see why you're using a BinaryReader at all. Why not just read
> > from the stream until it's exhausted, as if you were reading a file?
[quoted text clipped - 9 lines]
> native .Net string/char. Anyway, thanks for all the information, it was very
> informative.
I wasn't suggesting using a StreamReader. I was suggesting just using
Stream.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too