请帮我看看,上传文件哪里出错了!

szdotnet szdotnet 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
不知道为什么,不能上传文件,源文件如下:


private void Button1_Click(object sender, System.EventArgs e)
{
HttpFileCollection MyFileCollection = Request.Files;
string path = Server.MapPath("./");
MyFileCollection[0].SaveAs(path);
}


错误信息如下:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Source Error:

Line 53: string path = Server.MapPath("./");
Line 54: MyFileCollection[0].SaveAs(path);
Line 55: }
Line 56: }


Source File: c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs Line: 54
...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
szdotnet
.NET社区 62,274 成员 668,968 内容