I'm just curious about whether this is possible - I know how to download a file, but how can I download only the first 100KB of a file?
views:
90answers:
1
+6
A:
Try this:
string GetWebPageContent(string url)
{
string result = string.Empty;
HttpWebRequest request;
const int bytesToGet = 1000;
request = WebRequest.Create(url) as HttpWebRequest;
//get first 1000 bytes
request.AddRange(0, bytesToGet - 1);
// the following code is alternative, you may implement the function after your needs
using (WebResponse response = request.GetResponse())
{
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
result = sr.ReadToEnd();
}
}
return result;
}
Stolen from here.
Abe Miessler
2010-08-09 19:01:53