[Mono-list] System.Net.WebClient
Gonzalo Paniagua Javier
gonzalo@ximian.com
26 Jan 2003 09:01:41 +0100
>+ const int readSize = 4096;
>+ Stream networkStream = OpenRead (address);
>+ MemoryStream ms = new MemoryStream ();
>+ BinaryWriter bw = new BinaryWriter (ms);
>+ byte[] buf = new byte [readSize];
>+ int size = 0;
>+ do {
>+ size = networkStream.Read (buf, 0,
readSize);
>+ bw.Write (buf, 0, size);
>+ } while (size == readSize);
>+ networkStream.Close ();
>+ return ms.GetBuffer ();
You don't need the BinaryWriter. You can write the byte [] directly to
ms.
-Gonzalo