在图片上传得时候出现这样的错误是怎么回事啊,救急啊!System.UnauthorizedAccessException: 对路径“D:\Inetpub\wwwroot\毕业设计\goodsimages\mistake-suggestion.bmp”的访问被拒绝。
 在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, 
Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions
 options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) 
在 System.IO.FileStream..ctor(String path, FileMode mode) 
在 System.Web.HttpPostedFile.SaveAs(String filename)
 在 backmanage_addgoods.Button3_Click(Object sender, EventArgs e) 
位置 d:\Inetpub\wwwroot\毕业设计\backmanage\addgoods.aspx.cs:行号 76protected void Button3_Click(object sender, EventArgs e)
    {
        string filePath = "", fileExtName = "", mFileName, mPath;
        System.Text.StringBuilder strMsg = new System.Text.StringBuilder("上传文件信息;<hr color=red>");
        if ("" != fileup.PostedFile.FileName)
        {
            filePath = fileup.PostedFile.FileName;
            fileExtName = filePath.Substring(filePath.LastIndexOf(".") + 1);
            try
            {
                mPath = Server.MapPath("../goodsimages/");
                mFileName = filePath.Substring(filePath.LastIndexOf("\\") + 1);
  76.....              fileup.PostedFile.SaveAs(mPath + mFileName);
            }
            catch (Exception err)
            {
                Response.Write(err.ToString());
            }
        }
    }
我用GridView绑定商品的部分信息,当点击删除的时候总是出现下面的错误是怎么回事啊!
“/毕业设计”应用程序中的服务器错误。
--------------------------------------------------------------------------------索引超出范围。必须为非负值并小于集合大小。
参数名: index 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
参数名: index源错误: 
行 41:         
行 42:         strcon.Open();
行 43:         string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
行 44:         SqlCommand comm = new SqlCommand("delete from tb_goods where id=" + id, strcon);
行 45:         comm.ExecuteNonQuery();
 源文件: d:\Inetpub\wwwroot\毕业设计\backmanage\updategoods.aspx.cs    行: 43

解决方案 »

  1.   

    mPath = Server.MapPath("../goodsimages/");
    这句应该错了,应该是mPath = Server.MapPath("~/goodsimages/");
      

  2.   

    关于那个index只看那几行看不出什么错,不过一般报“索引超出范围。必须为非负值并小于集合大小。”这个错,就是index的值没有取到为空,你可以设置断点检查一下index的值