请帮我看看,上传文件哪里出错了!
不知道为什么,不能上传文件,源文件如下:
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