当前位置:首页 开发语言 正文
+7°

asp 中常用的文件处理函数

2011年06月06日 | 作者: 米豆网 - 1000seo | 分类: 开发语言 | 

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
””””””””””””””””””””””””””””””””””””
%>

本文固定链接:http://www.1000seo.com/soft/130
本文章由 米豆网 - 1000seo 于2011年06月06日发布在开发语言分类下,您可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
+复制链接 转载请注明:asp 中常用的文件处理函数-米豆网
关键字:, , , ,

好文章就要一起分享!

更多

目前共有7条留言

  • how much house can i afford

    1楼
    2011 年 09 月 08 日 18:54:45 回复

    i love your blog, i have it in my rss reader and always like new things coming up from it.

  • balLellBrak

    2楼
    2011 年 07 月 11 日 13:51:36 回复

    In my opinion you are mistaken. I can defend the position. Write to me in PM, we will communicate.

  • Blueloprene

    3楼
    2011 年 07 月 10 日 04:35:41 回复

    In my opinion it is very interesting theme. Give with you we will communicate in PM.

  • neappypet

    4楼
    2011 年 07 月 09 日 17:12:23 回复

    Good day! You some kind of skilled? Great message. Can you inform me how you can subscribe your blog?

    [url=http://touchsbasceben.net46.net]Lamp server download[/url]

  • Licscletirl

    5楼
    2011 年 07 月 06 日 08:38:55 回复

    It is remarkable, rather valuable information

  • Momatmoppex

    6楼
    2011 年 07 月 04 日 10:34:10 回复

    It is a pity, that now I can not express – I hurry up on job. But I will return – I will necessarily write that I think.

发表评论

你的大名(必填)

你的邮箱(必填)

你的网站(选填)

评论内容(必填)

😉 😐 😡 😈 🙂 😯 🙁 🙄 😛 😳 😮 mrgreen.png 😆 💡 😀 👿 😥 😎 ➡ 😕 ❓ ❗