欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【asp中常用的文件处理函数】,下面是详细的分享!
asp中常用的文件处理函数
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'所有自定义的VBS函数
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function DeleteFile(Filename) '删除文件
if Filename<>"" then
Set fso=server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(Filename) then
fso.DeleteFile Filename
end if
set fso=nothing
end if
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CreateDIR(byval LocalPath) '建立目录的程序,如果有多级目录,则一级一级的创建
on error resume next
LocalPath=replace(LocalPath,"\","/")
set FileObject=server.createobject("Scripting.FileSystemObject")
patharr=split(LocalPath,"/")
path_level=ubound(patharr)
for i=0 to path_level
if i=0 then pathtmp=patharr(0) & "/" else pathtmp=pathtmp & patharr(i) & "/"
cpath=left(pathtmp,len(pathtmp)-1)
if not FileObject.FolderExists(cpath) then FileObject.CreateFolder cpath
next
set FileObject=nothing
if err.number<>0 then
CreateDIR=false
err.Clear
else
CreateDIR=true
end if
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function SaveRandFileName(byval szFilename) '根据原文件名生成新的随机文件名
randomize
'ranNum=int(90000*rnd)+10000
'if month(now)<10 then c_month="0" & month(now) else c_month=month(now)
'if day(now)<10 then c_day="0" & day(now) else c_day=day(now)
'if hour(now)<10 then c_hour="0" & hour(now) else c_hour=hour(now)
'if minute(now)<10 then c_minute="0" & minute(now) else c_minute=minute(now)
'if second(now)<10 then c_second="0" & second(now) else c_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
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function jaron_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)
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function replaceplus(strContent,start_string,end_string,replace_string)
'文档中,将所有开始,结束之间的所有字符删除
on error resume next
MARKCOUNTS=ubound(split(strContent,start_string))
PRESTRING=strContent
for i=0 to MARKCOUNTS
STARTMARK=instr(1,PRESTRING,start_string,1)
if STARTMARK=0 then exit for
COMPMARK=instr(1,PRESTRING,end_string,1) + len(end_string)
VerString=mid(PRESTRING,STARTMARK,COMPMARK - STARTMARK)
PRESTRING=replace(PRESTRING,VerString,replace_string)
next
replaceplus=PRESTRING
if err.number<>0 then err.Clear
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
以上所分享的是关于asp中常用的文件处理函数,下面是编辑为你推荐的有价值的用户互动:
相关问题:asp文件如何执行.c文件中的函数
答:一般自己编写的函数如果是常用或需要重复使用的情况,都会将函数放至一个文件,需要调用的页面就先包含存放函数的文件。这样便于维护!! 希望回答能给你带来帮助~ 如果满意,请采纳,如还有疑问,可继续追问! 您也可以向我们团队发出请求,会... >>详细
相关问题:asp 中用button调用函数
答:一个是服务端,一个是客户端,你没分清楚,这是初学者最容易犯的错误了。 如果你希望点击按钮后执行ASP中的函数可以这样: 然后再改ASP代码: >>详细
相关问题:asp如何调用dll文件里的函数
答:现在做的asp.net供应链管理系统因为要与该公司的oa办公系统共处,所以需要调用oa办公系统中dll中的一个加密函数 调用的步骤如下: 一、开始-运行,输入 regsvr32 "x:\path\yourdll.dll" 其中x:\path\yourdll.dll代表你的VB的dll的路径和文件名。... >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
