C#删除图片
SqlConnectionobjSqlConnection=newSqlConnection(System.Configuration.ConfigurationSett...
SqlConnection objSqlConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnString"]);
objSqlConnection.Open();
//删除图片
string str1="select * from lnjg where id="+i;
SqlCommand myOldCom1=new SqlCommand(str1,objSqlConnection);
SqlDataReader dr=myOldCom1.ExecuteReader();
if(dr.Read())
{
if(File.Exists (Server.MapPath(""+dr["img"].ToString())))
{
FileInfo fi=new FileInfo(Server.MapPath(""+dr["img"].ToString()));
fi.Delete();
}
}
dr.Close();
删除不了图片。。是代码问题吗 展开
objSqlConnection.Open();
//删除图片
string str1="select * from lnjg where id="+i;
SqlCommand myOldCom1=new SqlCommand(str1,objSqlConnection);
SqlDataReader dr=myOldCom1.ExecuteReader();
if(dr.Read())
{
if(File.Exists (Server.MapPath(""+dr["img"].ToString())))
{
FileInfo fi=new FileInfo(Server.MapPath(""+dr["img"].ToString()));
fi.Delete();
}
}
dr.Close();
删除不了图片。。是代码问题吗 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询