Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpWebRequest AddRange Method Query

Tags:

c#

http

In HttpWebRequest AddRange method, we can specify the range of byte to download. What I want to know is how to specify my range from a certain offset upto the end of file.

Like if we don't know the length of the file, we can specify like this in the Request Header string

"Range: bytes = 0 - " This means, starting from the first byte upto the end of file.

But using the method AddRange, how to specify this with one offset value to the EOF??

I know I can get the content length and specify like this, AddRange(0, ContentLength). But I am asking if there is any way to get the contents upto EOF from a certain 'offset' value.

like image 224
Prasenjit Chatterjee Avatar asked Nov 22 '25 14:11

Prasenjit Chatterjee


1 Answers

You use a positive value to the AddRange method to get bytes from the offset to the end of entity;

 request.AddRange(10)

Tells the server to return all bytes except the first 10.

You can use a negative value, which is the ending point;

 request.AddRange(-10)

Tells server to return bytes 0 to 10.

like image 132
Richard Schneider Avatar answered Nov 25 '25 02:11

Richard Schneider



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!