Re: Is there a clean way to create a byte[] from an HttpWebRequest.Read?
- From: "Marc Gravell" <marc.gravell@xxxxxxxxx>
- Date: 2 Oct 2006 22:07:30 -0700
Snippet is unreliable; assumes < 20K bytes, and manual copy (instead of
buf.CopyTo() or Buffer.BlockCopy()) is inneficient. Perhaps read (in a
loop, using a smaller buffer) from the response and writing to a
MemoryStream, then call ms.ToArray()? This would work with any size.
In 2.0, you could instead use WebClient:
byte[] data;
using (WebClient wc = new WebClient()) {
data = wc.DownloadData("http://somewhere");
}
Marc
.
- Follow-Ups:
- Re: Is there a clean way to create a byte[] from an HttpWebRequest.Read?
- From: John Wilmot
- Re: Is there a clean way to create a byte[] from an HttpWebRequest.Read?
- References:
- Is there a clean way to create a byte[] from an HttpWebRequest.Read?
- From: John Wilmot
- Is there a clean way to create a byte[] from an HttpWebRequest.Read?
- Prev by Date: Re: Is this safe
- Next by Date: windows service with process.start()
- Previous by thread: Is there a clean way to create a byte[] from an HttpWebRequest.Read?
- Next by thread: Re: Is there a clean way to create a byte[] from an HttpWebRequest.Read?
- Index(es):
Relevant Pages
|