批量删除图片
protected void BtnAllDel_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(HSelectID.Value.Trim()))
{
string strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("..\\App_Data\\default.mdb");
string sql2 = "select id,name,images from product where id in (" + HSelectID.Value.Trim() + ")";
string sql = "delete from product where id in(" + HSelectID.Value.Trim() + ")";
OleDbConnection con = new OleDbConnection(strconn);
OleDbDataAdapter sda = new OleDbDataAdapter(sql2, strconn);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string filepath = dt.Rows[0]["images"].ToString();
File.Delete(Server.MapPath("../product1/" + filepath));
File.Delete(Server.MapPath("../product/" + filepath));
}
}
con.Open();
OleDbCommand co2 = new OleDbCommand(sql, con);
co2.ExecuteNonQuery();
con.Close();
Get_griv();
}
}
这里
for (int i = 0; i < dt.Rows.Count; i++)
{
string filepath = dt.Rows[0]["images"].ToString();
怎么判断循环每次的图片值啊。
请高手指点。。