删除图片中出现的问题

girl013579 2007-12-28 06:56:50
SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["Connstr"]);
string SQL = "select ImageUrl from gonggaoxinxi where zhanhui_id='" + e.CommandName + "'";
SqlCommand cmd = new SqlCommand(SQL,mycon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@zhanhui_id",SqlDbType.Int);
cmd.Parameters["@zhanhui_id"].Value = SQL;
mycon.Open();
string filePath = @"images\NewsPic\" + cmd.ExecuteScalar().ToString();
if(File.Exists(filePath))
{
File.Delete(filePath) ;
}
...全文
75 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zfh198601 2007-12-29
  • 打赏
  • 举报
回复
路径不对,你取的是绝对路径.但是我也不知道取相对路径
girl013579 2007-12-29
  • 打赏
  • 举报
回复
cmd.Parameters["@zhanhui_id"].Value = SQL;

不好意思,昨天发完贴忘记了,是上面这行错误
xierfly 2007-12-28
  • 打赏
  • 举报
回复
想赚点分,都没机会,什么错误呀,lz!
haiwangstar 2007-12-28
  • 打赏
  • 举报
回复
什么错误? 也不说? 看看filePath得到的是什么?? 最可能的是路径不对。
catvv 2007-12-28
  • 打赏
  • 举报
回复
cmd.CommandType = CommandType.Text;
catvv 2007-12-28
  • 打赏
  • 举报
回复
SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["Connstr"]);
string SQL = "select ImageUrl from gonggaoxinxi where zhanhui_id=@zhanhui_id";
SqlCommand cmd = new SqlCommand(SQL,mycon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@zhanhui_id",SqlDbType.Int);
cmd.Parameters["@zhanhui_id"].Value = e.CommandName;
mycon.Open();
string filePath = @"images\NewsPic\" + cmd.ExecuteScalar().ToString();
if(File.Exists(filePath))
{
File.Delete(filePath) ;
}

110,546

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧