HttpPostedFile hf = Request.Files[0];//取得控件
if (hf.ContentLength > 0)//是否有文件
{
int fileSize = 0;
fileSize = hf.ContentLength;//取得大小
if (fileSize < 2097152)//判断大小 单位字节
{ }
else
{
//报错处理
customException.addErrorCode("xxxxxxx文件", "DSKSE130");
showMsg(customException);
return;
}
}
本文详细介绍了如何在Web应用程序中使用C#处理HTTP上传文件的大小限制,并提供了错误处理策略,确保程序稳定性和用户体验。
874

被折叠的 条评论
为什么被折叠?



