zoukankan      html  css  js  c++  java
  • 删除冗余文件

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

    <!--#include file="Conndb.asp"-->

    <%Sub   DelSpilthFile(Table,tField,FilePath)  
         '***********************************************  
      '过程名:DelSpilthFile  
      '作 用:删除数据库里冗余的上传文件  
      '参 数:Table:数据表  
      ' tField:图片字段名  
      ' FilePath:图片相对文件夹  
       

      '***********************************************  
          Dim   FileUrl,fso,f,fc,fi,fu,ff,fb  
       
          sql   =   "Select   *   From   ["   &   Table   &   "]"  
          Set   Rs   =   Server.CreateObject("Adodb.RecordSet")  
          Rs.Open   sql,conn,1,1  
          Do   While   Not   Rs.Eof  
            fb     =   Split(tField,",")  
            For   Each   ff   in   fb  
              If   Rs(ff)   <>   ""   and   Not   IsNull(Rs(ff))   Then  
                fu   =   fu   &   Rs(ff)  
                fu   =   fu   &   "|"  
              End   If  
            Next  
            Rs.MoveNext  
          Loop  
          Rs.Close  
          Set   Rs   =   Nothing  
       
          FileUrl   =   Server.MapPath(FilePath)  
          Set   fso   =   Server.CreateObject("Scripting.FileSystemObject")  
          Set   f     =   fso.GetFolder(FileUrl)  
          Set   fc   =   f.Files  
          For   Each   fi   in   fc  
            If   InStr(fu,fi.name   &   "|")   =   0   Then  
              If   fso.FileExists(fi)   Then  
                fso.DeleteFile(fi)       '删除文件  
              End   If  
            End   If  
          Next  
           
          Set   fso   =   Nothing  
          Set   f     =   Nothing  
          Set   fc   =   Nothing  
      End   Sub  
    %>   
       
      Example:  
    <% Call   DelSpilthFile("product","DefaultPicUrl","../UpLoadFiles/") %>

  • 相关阅读:
    hdu 3415 Max Sum of MaxKsubsequence
    poj 2243 Knight Moves
    【LCD手册】飞凌3.5/4.3/5.6/7/8 寸LCD手册大全下载
    【转载zq2002好文章】Windows CE 休眠唤醒全面解析(基于2440平台)(1)(2)(3)
    【转载】如果做到窗口自动适应不同尺寸屏幕的尺寸?
    【转载】wince6.0+s3c6410摄像头驱动修改
    推荐一个比较活跃的ARM/WinCE/LinuxQQ群
    【转载】微软的USB摄像头驱动,
    【收集】ARM+WinCE QQ 群
    【转载】S3C6410移植日记系列
  • 原文地址:https://www.cnblogs.com/zerogo/p/2209358.html
Copyright © 2011-2022 走看看