温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:chx99个人主页源码
当前文件:
chx99/admin/delimg.aspx.cs[1K,2009-6-12 11:35:58],打开代码结构图
chx99/admin/delimg.aspx.cs[1K,2009-6-12 11:35:58],打开代码结构图1using System; 2
using System.Collections; 3
using System.Configuration; 4
using System.Data; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.HtmlControls; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
using System.IO; 12
using System.Data.OleDb; 13
14
public partial class admin_delimg : System.Web.UI.Page 15
{ 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
if (Request.QueryString["did"] != null) 19
{ 20
try 21
{ 22
int id = Convert.ToInt32(Request.QueryString["did"]); 23
24
ImgUploads ui = new ImgUploads(); 25
26
//删除文件 27
DataSet ds = ui.GetID(id); 28
DataTable dt = ds.Tables[0]; 29
string Ipath = Server.MapPath("../" + dt.Rows[0]["path"].ToString()); 30
File.Delete(Ipath); 31
32
//删除缩略图 33
string Tpath = Server.MapPath("../thumbar/"+dt.Rows[0]["id"].ToString()+".jpg"); 34
File.Delete(Tpath); 35
36
37
//删除数据库记录 38
ui.DelImg(id); 39
Page.RegisterStartupScript("123", "<script>alert('删除成功!');location.href='manimg.aspx?id=" + Request.QueryString["id"].ToString() + "'</script>"); 40
} 41
catch(Exception ex) 42
{ 43
Page.RegisterStartupScript("error","<script>alert('删除失败,请重试"+ex.Message.ToString()+"');location.href='manimg.aspx?id="+Request.QueryString["id"].ToString()+"'</script>"); 44
} 45
} 46
} 47
} 48






}
}