I am trying to get the total bytes of all files in the "Request.Files" collection upon a request coming in to my web application.
This for(;;) loop works flawlessly but I don't understand why I can't do it using the LINQ technology:
var total_bytes = 0;
for (int i = 0; i < Request.Files.Count; i++)
{
total_bytes += Request.Files[i].ContentLength;
}
I have tried the following code with no success.
var result1 = Request.Files.Cast<HttpPostedFileWrapper>();
var total_bytes = result1.Sum(o => o.ContentLength);
Can somebody please help me find the error in my programming logic. Thank You.
...
Go to the complete details ...