当前位置: 网学 > 编程文档 > ASP > 正文

asp中常用的文件处理函数

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/17
下载{$ArticleTitle}原创论文样式

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替换函数:源字符串,前部分,后部分,替换成

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号