I have a function that has a parameter of type HttpPostedFileBase and I'm getting the file's name using (Path.GetFileName):
public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments)
{
foreach (var file in attachments)
{
var fileName = Path.GetFileName(file.FileName);
}
}
How can I get the file size??
The ContentLength
property on the HttpPostedFileBase
class contains the number of bytes in the posted file
int byteCount = file.ContentLength;
See this link for more information:
http://msdn.microsoft.com/en-us/library/system.web.httppostedfilebase.contentlength.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With