开发者

Read several byte from file via http c#

How to download开发者_如何学C first 200 bytes of a file via HTTP protocol using C#?

I believed it could be done like this:

WebClient wc = new WebClient();
byte[] buffer = new byte[200];
using (var stream = wc.OpenRead(fileName))
{
     stream.Read(buffer, 0, 200);
}

but when wc.OpenRead it called it downloads the whole file.


You need to set a Range Header on your WebClient before you invoke the OpenRead method.

See: http://msdn.microsoft.com/en-us/library/system.net.webclient.headers.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜