sqltxt = "SELECT p_img FROM products ORDER BY p_date DESC";
        dt = db.GetDataTable(sqltxt);
        for (i = 0; i < dt.Rows.Count;i++ )
        {
            string pimg = dt.Rows[i]["p_img"].ToString();
            if (System.IO.File.Exists(Server.MapPath("images/" + pimg)))//检测文件夹里是否有此图片
            {
            //System.IO.File.Delete(Server.MapPath("~/images/" + pimg));
                System.IO.File.Copy(Server.MapPath("images/" + pimg),Server.MapPath("images/a/" + pimg));
            }
        }数据库里保存的图片中径为allproductimg/1.jpg,图片放在images文件夹下,里面有很多图片有些是我不需要的.
现在我要把需要的图片拷贝到images/a文件夹下
提示未能找到路径“E:\客户网站\unet\images\a\allproductimg\1.jpg”的一部分

解决方案 »

  1.   

    a文件夹是否存在?如果存在,给他赋予aspnet对应用户写的权限。
      

  2.   

    还是一样,如果改成
    System.IO.File.Copy(Server.MapPath("images/" + pimg),Server.MapPath("images/a/"));
    未能找到路径“E:\客户网站\unet\images\a\”的一部分
      

  3.   

    检查a文件夹下allproductimg\1.jpg是否存在Copy的第二个参数://   destFileName:
    //     目标文件的名称。它不能是一个目录或现有文件。