您的位置:网大 >> 网络 >> 网络大全 >> 正文

asp中常用的文件处理函数

作者:不详时间:2006-3-7 13:56:36

asp中处理文件上传以及删除时常用的自定义函数:

<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'所有自定义的VBS函数
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
functionDeleteFile(Filename)'删除文件
ifFilename<>""then
Setfso=server.CreateObject("Scripting.FileSystemObject")
iffso.FileExists(Filename)then
fso.DeleteFileFilename
endif
setfso=nothing
endif
endfunction
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
functionCreateDIR(byvalLocalPath)'建立目录的程序,如果有多级目录,则一级一级的创建
onerrorresumenext
LocalPath=replace(LocalPath,"\","/")
setFileObject=server.createobject("Scripting.FileSystemObject")
patharr=split(LocalPath,"/")
path_level=ubound(patharr)
fori=0topath_level
ifi=0thenpathtmp=patharr(0)&"/"elsepathtmp=pathtmp&patharr(i)&"/"
cpath=left(pathtmp,len(pathtmp)-1)
ifnotFileObject.FolderExists(cpath)thenFileObject.CreateFoldercpath
next
setFileObject=nothing
iferr.number<>0then
CreateDIR=false
err.Clear
else
CreateDIR=true
endif
endfunction

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
functionSaveRandFileName(byvalszFilename)'根据原文件名生成新的随机文件名
randomize
'ranNum=int(90000*rnd)+10000
'ifmonth(now)<10thenc_month="0"&month(now)elsec_month=month(now)
'ifday(now)<10thenc_day="0"&day(now)elsec_day=day(now)
'ifhour(now)<10thenc_hour="0"&hour(now)elsec_hour=hour(now)
'ifminute(now)<10thenc_minute="0"&minute(now)elsec_minute=minute(now)
'ifsecond(now)<10thenc_second="0"&second(now)elsec_second=minute(now)
fileExt_a=split(szFilename,".")
fileExt=lcase(fileExt_a(ubound(fileExt_a)))

SaveRandFileName=replace(replace(replace(now,":",""),"-",""),"","")&int(10*rnd)&"."&fileExt
'GenerateRandomFileName=year(now)&c_month&c_day&c_hour&c_minute&c_second&"_"&ranNum&"."&fileExt
endfunction
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

functionjaron_replacer(strContent,start_string,end_string,replace_string)
'CMS替换函数:源字符串,前部分,后部分,替换成的字符
'返回被替换后的字符串
jaron_replacer=replace(strContent,mid(strContent,instr(strContent,start_string),instr(strContent,end_string)+len(end_string)-1),replace_string)
endfunction
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
functionreplaceplus(strContent,start_string,end_string,replace_string)
'文档中,将所有开始,结束之间的所有字符删除
onerrorresumenext
MARKCOUNTS=ubound(split(strContent,start_string))
PRESTRING=st


评论数: 来源:不详


网大首页 - 网站地图 - 广告服务 - 关于网大 - 招聘信息 - 联系我们
Copyright (C) 1999-2005 NETBIG.COM (CHINA) LIMITED All Rights Reserved
粤B-20050190