asp中常用的文件处理函数
作者:佚名 来源:3lian.com 时间:2009-01-08 18:09:00
asp 中处理文件上传以及删除时常用的自定义函数:
删除文件,建立目录的程序,根据原文件名生成新的随机文件名,CMS替换函数,将所有开始,结束之间的所有字符删除
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'所有自定义的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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
标签:文件,函数,fso,asp
0
投稿
猜你喜欢
asp读取xml实例代码
2011-03-08 11:13:00
ASP中的Debug类--VBScript
2008-10-24 09:38:00
phpmyadmin 数据导入导出问题
2007-08-06 15:23:00
页面表达常用方式
2010-05-27 12:42:00
网页设计之关于素材和言志
2008-03-23 13:46:00
从开发人员角度看IE8的开发新特性
2010-02-26 10:48:00
MySQL数据库性能优化之索引优化
2012-05-08 07:16:37
垂直无缝滚动图片(兼容性好)实例教程源码下载
2010-04-06 12:16:00
W3C Group的JavaScript1.8新特性介绍
2009-07-24 12:31:00
Yahoo! BrowserPlus 发布
2008-11-20 13:35:00
形象化的reflow
2008-06-08 13:33:00
服务器XMLHTTP(Server XMLHTTP in ASP)基础
2008-11-11 12:45:00
CSS技巧之圆角背景与三角形
2010-10-19 12:40:00
个人经验总结:完全卸载MySQL数据库5.0
2009-01-04 13:07:00
清除SQL被注入恶意病毒代码的语句
2010-03-03 09:59:00
Mysql中日期和时间函数介绍
2008-05-24 08:16:00
利用xmlhttp和adodb.stream加缓存技术下载远程Web文
2009-04-23 18:33:00
用SQL语句生成带有小计合计的数据集脚本
2009-01-06 11:33:00
css特性:空白外边距互相叠加
2010-06-21 10:53:00
Oracle逗号分隔列转行实现方法
2011-01-04 20:13:00