当前位置: 诺豆网 > 编程开发

删除网站里无用的图片

2009年03月17日 haibor 发表评论(0)

某产品管理系统做的不完善,删除产品记录的时候,指定图片没有删除,现在要来个大清理。

<!--#include file="inc/conn.asp"-->

<%

Dim strSql,currentPath

Dim Fso

Set Fso = Server.CreateObject("Scripting.FileSystemObject")

Dim Fol



currentPath = Server.MapPath("product_pic")



If Fso.FolderExists(currentPath) Then

Dim RS

Set RS = Server.CreateObject("ADODB.RecordSet")



Set Fol=Fso.GetFolder(currentPath)

Set Fles=Fol.Files



For Each Item In Fles

strSql = "Select * from product where productPicture='" & Item.Name & "'"

RS.Open strSql,conn

If RS.EOF Then

Fso.DeleteFile currentPath & "\" & Item.Name

End If

RS.Close

Next



Set RS = nothing

Else

Response.Write "目录不存在。"

Response.End

End If



conn.close

Set conn = nothing

%>

清理完毕

订阅

发表评论

您的昵称 *

您的邮箱 *

您的网站

无觅相关文章插件,快速提升流量