文件在目录里删除的关键代码!

//加入到相关的页面

<!--#include file="function.asp" -->
<%
Const SaveUpFilesPath="图片存储的相对路径"
dim strFileName
dim UploadDir,TruePath,fso,theFolder,theFile,whichfile,thisfile,FileCount,TotleSize
strFileName="本页面的文件名.asp"


if right(SaveUpFilesPath,1)<>"/" then
     UploadDir="../" & SaveUpFilesPath & "/"
else
     UploadDir="../" & SaveUpFilesPath
end if
TruePath=Server.MapPath(UploadDir)
If not IsObjInstalled("Scripting.FileSystemObject") Then
     Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
Else
     set fso=CreateObject("Scripting.FileSystemObject")
     if request("Action")="Del" then
           whichfile=server.mappath(Request("FileName"))
           Set thisfile = fso.GetFile(whichfile)
           thisfile.Delete True
end if
%>

function.asp


<%
'*************************************************
'函数名:gotTopic
'作  用:截字符串,汉字一个算两个字符,英文算一个字符
'参  数:str   ----原字符串
'       strlen ----截取长度
'返回值:截取后的字符串
'*************************************************
function gotTopic(str,strlen)
     if str="" then
           gotTopic=""
           exit function
     end if
     dim l,t,c, i
     str=replace(replace(replace(replace(str,""," "),""",chr(34)),">",">"),"<","<")
     l=len(str)
     t=0
     for i=1 to l
           c=Abs(Asc(Mid(str,i,1)))
           if c>255 then
                 t=t+2
           else
                 t=t+1
           end if
           if t>=strlen then
                 gotTopic=left(str,i) & "…"
                 exit for
           else
                 gotTopic=str
           end if
     next
     gotTopic=replace(replace(replace(replace(gotTopic," ",""),chr(34),"""),">",">"),"<","<")
end function

'***********************************************
'函数名:JoinChar
'作  用:向地址中加入 ? 或 &
'参  数:strUrl  ----网址
'返回值:加了 ? 或 & 的网址
'***********************************************
function JoinChar(strUrl)
     if strUrl="" then
           JoinChar=""
           exit function
     end if
     if InStr(strUrl,"?")<len(strUrl) then
           if InStr(strUrl,"?")>1 then
                 if InStr(strUrl,"&")<len(strUrl) then
                       JoinChar=strUrl & "&"
                 else
                       JoinChar=strUrl
                 end if
           else
                 JoinChar=strUrl & "?"
           end if
     else
           JoinChar=strUrl
     end if
end function




'***************************************************
'函数名:IsObjInstalled
'作  用:检查组件是否已经安装
'参  数:strClassString ----组件名
'返回值:True  ----已经安装
'       False ----没有安装
'***************************************************
Function IsObjInstalled(strClassString)
     On Error Resume Next
     IsObjInstalled = False
     Err = 0
     Dim xTestObj
     Set xTestObj = Server.CreateObject(strClassString)
     If 0 = Err Then IsObjInstalled = True
     Set xTestObj = Nothing
     Err = 0
End Function



%>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值