Httppostedfilebase.ContentLength.Tostring() returns "0"

Asked

Viewed 35 times

0

Follows code:

HttpFileCollectionBase files;

I get the file size like this:

var tamanho = files[0].ContentLength; //tamanho é 1250

So far works normal when I want to convert to string:

var tamanho = files[0].ContentLength.ToString(); //para string "0"

With ToString() returns "0". Why does that happen ?

Update:

The following code works:

var tamanho = files[0].ContentLength;
var tamanho_string = tamanho.ToString(); //funciona "1250"

When I do ToString() direct, ex:

var tamanho = files[0].ContentLength.ToString(); // "0"
  • are you declaring the file as in the question or are you assigning a value to it? Ex: HttpFileCollection files = HttpContext.Current.Request.Files;

  • @Leandroangelo assigning a value to him

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.