C
Chizl
I'm trying to add 206 Partial content to my web server and I'm getting
errors each time I try using the offset from the Read command. Maybe I'm
not understanding the Read() command. I've scaled this demo back, but in
reality the file is 3.8GB, I need to send chunks of 100KB down to the
browser, but I need it to start with byte 106954752. The error doesn't make
sense to me, because it shouldn't be looking at my array it should be
looking at the file. The array should only be the storage. I even tried
adding the iStartBytes and iMaxSize together thinking maybe it's not wanting
the size, but where the end of the read should be. Same error.
The error is:
--------
Offset and length were out of bounds for the array or count is greater than
the number of elements from index to the end of the source collection.
--------
FileStream fs = new FileStream(sPhysicalFilePath, FileMode.Open,
FileAccess.Read, FileShare.Read);
BinaryReader reader = new BinaryReader(fs);
long lSize = fs.Length; //10MB
if(lSize>1048576) //no more than 1MB at a time
lSize=1048576;
byte[] bytes = new byte[lSize];
Int32 iMaxSize = bytes.Length; //1MB
Int32 iStartBytes = 2097152; //2MB Mark
//based on my params, I would assume I could start picking up
//the file at the 2MB mark and only get 1MB of data, but I get the error on
this line..
while ((read = reader.Read(bytes, iStartBytes, iMaxSize)) != 0)
{
.....
}
errors each time I try using the offset from the Read command. Maybe I'm
not understanding the Read() command. I've scaled this demo back, but in
reality the file is 3.8GB, I need to send chunks of 100KB down to the
browser, but I need it to start with byte 106954752. The error doesn't make
sense to me, because it shouldn't be looking at my array it should be
looking at the file. The array should only be the storage. I even tried
adding the iStartBytes and iMaxSize together thinking maybe it's not wanting
the size, but where the end of the read should be. Same error.
The error is:
--------
Offset and length were out of bounds for the array or count is greater than
the number of elements from index to the end of the source collection.
--------
FileStream fs = new FileStream(sPhysicalFilePath, FileMode.Open,
FileAccess.Read, FileShare.Read);
BinaryReader reader = new BinaryReader(fs);
long lSize = fs.Length; //10MB
if(lSize>1048576) //no more than 1MB at a time
lSize=1048576;
byte[] bytes = new byte[lSize];
Int32 iMaxSize = bytes.Length; //1MB
Int32 iStartBytes = 2097152; //2MB Mark
//based on my params, I would assume I could start picking up
//the file at the 2MB mark and only get 1MB of data, but I get the error on
this line..
while ((read = reader.Read(bytes, iStartBytes, iMaxSize)) != 0)
{
.....
}