开发者

How to get size of HttpPostedFileBase file

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(fil开发者_如何学Goe.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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜