- <%
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- '所有自定义的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 中常用的文件处理函数
2019-11-01 12:52asp教程网 ASP教程
asp 中处理文件上传以及删除时常用的自定义函数
延伸 · 阅读
- 2021-10-20关于ASP网页无法打开的解决方案
- 2021-10-14让apache也支持asp环境的方法
- 2021-08-15asp取整数mod 有小数的就自动加1
- 2021-08-15asp与php中定时生成页面的思路与代码
- 2021-05-09IIS 7.5 asp Session超时时间设置方法
- 2021-03-05js实现的类似于asp数据字典的数据类型代码实例
精彩推荐
- ASP教程
ASP 判断是否有中文的代码
其实我上一篇写的js判断中文才是最好的方法,这个是asp的一种,只要是双字节都是当作中文判断...
- ASP教程
ASP常用函数:HTMLDecode
ASP常用函数:HTMLDecode ...
- ASP教程
ASP GetRef 函数指针试探
近日在学习C++,看到函数指针,由于之前一直搞ASP,所以想ASP里面是否也有这个函数指针的东西,百度了一下,没有太多关于此方面的介绍,于是翻了翻...
- ASP教程
asp中一段防SQL注入的通用脚本
asp中一段防SQL注入的通用脚本...
- ASP教程
字符批量替换程序asp服务器版
字符批量替换程序asp服务器版,安装方法:直接把replace.asp文件放在任意的支持asp+FSO的环境中 ...
- ASP教程
asp读取远程文件并保存到本地代码
asp读取远程文件并保存到本地代码 ...
- ASP教程
ASP实现文件上传的方法
在基于浏览器/服务器的应用环境中,在浏览器中上传各种类型的文件一直是困扰用户文件管理应用的难题之一。常用的实现方法是利用在RFC1867中引入的一...
- ASP教程
asp删除mssql数据库中没有记录的图片代码
asp删除没有记录的图片需要文件夹(存放图片的文件夹)中的每个图片和数据库中的所有记录进行比较...