隨筆 - 8  文章 - 55  trackbacks - 0
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(6)

          隨筆分類(lèi)

          隨筆檔案

          文章分類(lèi)

          文章檔案

          朋友的Blog

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          asp刪除文件的函數(shù)(三個(gè))
          [不指定 2006/04/14 01:06 | by admin ]


          <%
          ''文件刪除函數(shù)
          function deletefile(filename)
          if filename<>"" then
          set fso=server.CreateObject("scripting.filesystemobject")
          if fso.FileExists(filename) then
          fso.DeleteFile filename
          else
          Response.Write "<script>alert(''該文件不存在'');</script>"
          end if
          end if
          end function

          strfile=server.MapPath("fileName")
          deletefile(strfile)
          %>





          '程序名:delfile.asp
          '關(guān)鍵參數(shù):struploadfiles 文件名稱(chēng)
          例:<a href="/delfile.asp?action=test.rar">刪除test.rar文件</a>

          <%
          struploadfiles=trim(request.querystring("struploadfiles"))
          action=trim(request.querystring("action"))
          response.write "成功刪除<font color=red>"&struploadfiles&"</font>文件!"
          call delfiles(struploadfiles & "")
          sub delfiles(struploadfiles)
          if struploadfiles="" then exit sub
          dim fso,arruploadfiles,i
          set fso = createobject("scripting.filesystemobject")
          fso.deletefile(server.mappath("" & struploadfiles))
          set fso = nothing
          response.write"<script language=javascript>alert('成功刪除文件,將返回上一頁(yè)!');"
          response.write"this.location.href='javascript:history.back();'</script>"
          end sub
          %>





          <%
          ''文件刪除函數(shù)
          function deletefile(filename)
          if filename<>"" then
          set fso=server.CreateObject("scripting.filesystemobject")
          if fso.FileExists(filename) then
          fso.DeleteFile filename
          else
          Response.Write "<script>alert(''該文件不存在'');</script>"
          end if
          end if
          end function

          strfile=server.MapPath("fileName")
          deletefile(strfile)
          %>

          Function?DeleFile(FilePath)
          ????On?Error?Resume?Next
          ????Set?Del=Server.CreateObject("Scripting.FileSystemObject")
          ????if?Err?<>?0?Then?
          ????????DelFile="該空間不支持FSO組件,無(wú)法刪除文件!"
          ????else
          ????????if?InStr(FilePath,?",")?>?0?then
          ????????????FilePath=Split(FilePath,",")
          ????????????For?i?=?0?to?ubound(FilePath)
          ????????????????If?Del.FileExists(Server.MapPath(FilePath))=True?Then?Del.DeleteFile?Server.MapPath(FilePath(i)),true
          ????????????Next

          ???????Else
          ????????????If?Del.FileExists(Server.MapPath(FilePath))=True?Then?Del.DeleteFile?Server.MapPath(FilePath),true
          ????????End?if
          ????End?if
          ????Set?Del=Nothing
          End?Function


          posted on 2006-06-15 14:10 blog搬家了--[www.ialway.com/blog] 閱讀(1220) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): PHP
          主站蜘蛛池模板: 瑞金市| 博湖县| 梅州市| 北京市| 哈巴河县| 芜湖县| 永济市| 莆田市| 临潭县| 丹阳市| 来宾市| 石屏县| 宜川县| 囊谦县| 长海县| 富锦市| 垣曲县| 调兵山市| 尼玛县| 昌宁县| 咸阳市| 福泉市| 永泰县| 黔东| 罗江县| 南昌市| 沿河| 蕲春县| 青州市| 邢台市| 萨嘎县| 海原县| 义马市| 响水县| 合山市| 清涧县| 通化县| 上犹县| 理塘县| 弥勒县| 弥渡县|