采用双重循环。把图片进行“.”分割后名字问前面部分,那其余数据库中的 图片路径记录进行对比 采用vb的InStr函数 如果存在的话返回值>0,过可以得出结论 代码如下deal.asp 复制代码 代码如下:<%@ language="vbscript"%> <%response.Expires = 0%> <!--#include file="conn.asp"--> <% Dim objFSO,objFolder,objFile,FF '声明 objFSO 变量存放对象实例 FF = Server.MapPath("pro_s/") Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(ff) Then Response.write "文件夹 "&ff&" 里所有的文件:<br>" Set objFolder = objFSO.GetFolder(ff) For Each objFile in objFolder.Files %> <% filename=cstr(objFile.name) myname=split(filename,".") ffname=myname(0) a=0 set sclass=conn.execute("select img from wksc_pro ") do while not sclass.eof result=Instr(sclass("img"),ffname) a=a+result if(a>0) then exit do end if sclass.movenext loop if(a=0) then response.Write ""&objFile&"" response.Write"<br>" objFile.delete end if %> <% Next Else Response.Write "文件夹"&ff&"不存在,无法读取相关信息!" End If Set objFolder = Nothing Set objFSO = Nothing '释放 FileSystemObject 对象实例内存空间 %>来自:http://blog.csdn.net/lingfeng179/archive/2009/08/19/4463679.aspx
推荐阅读
asp base64 utf-8为了兼容asp.net的base64
复制代码 代码如下:<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <%Session.CodePage=65001%> <!--#include file="base64.asp"--> <% Function AspUrlDecode(strValue) Dim varAry, varElement, objStream, lngLoop>>>详细阅读
本文标题:asp删除mssql数据库中没有记录的图片代码
地址:http://www.17bianji.com/kaifa2/ASP/32017.html
1/2 1