asp中常用的文件处理函数
作者:佚名 来源:3lian.com 发布时间:2009-01-08 18:09:00
标签:文件,函数,fso,asp
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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
0
投稿
猜你喜欢
- 加入CDC的这段日子里,工作中积累的小心得都密密麻麻的收在册子里。恰逢近期的校园招聘正如火如荼的展开着,借此机会,我把这一些不太成熟的小想法
- 管理SQL Server内在的帐户和密码时,我们很容易认为这一切都相当的安全。但实际上并非如此。在这里,我们列出了一些对于SQL Serve
- 初步介绍 当然,我知道现在有成千上万个关于 用CSS处理圆角 的教程,但不管怎么说,我仍然想把这篇文章展示给您。也希望您会发现这篇文章会非常
- 最近因项目需要用ACCESS做数据库开发WEB项目看论坛上还许多人问及ACCESS被注入的安全问题许多人解决的方法仍然是用Replace替换
- 本文的asp xmlhttp类,使用asp的MSXML2.ServerXMLHTTP组件来获取远程音乐文件。类定义 Cls_AspHttp.
- 请问,如何在ACCESS数据库和SQL SERVER数据库中查询?
- 一、输出指令ASP的输出指令<% =expression %>显示表达式的值。这个输出指令等同于使用Resp
- SQL Server2005数据项的分拆与合并:参考示例如下:-- ====================================
- MySQL安装文件已被广泛应用但是也在不断的更新,这里介绍MySQL安装文件设置使用,帮助大家安装更新MySQL安装文件系统。Fedora5
- 1。建立数据库表 表名为online 设如下字段 id '用来记录每一个访问都的session.sessionid name
- 说明:通过随机产生密码,然后将密码EMail给注册用户,你可以确认用户的EMail填写是否正确。自动产生的密码往往安全性更高,同时,你可以过
- 如何用JMail同时给多人发信?在ASP中,为什么我在Jmail收件人处指定多个收件人时,像这样:JMail.AddRecipient&nb
- IE6下浮出层常会需要增加一个iframe来解决浮出层被Obj穿透的问题,这个是目前最有效的方案,不过这个方案本身有个缺陷,就是iframe
- 1、HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Applicatio
- 在线阅读与印刷品阅读有着很大的不同,原因之一是屏幕会导致注意力问题。文字很难成为重点,而闪烁的横幅、明亮的图片又更加会转移对实际的博客内容的
- 概要本文分步介绍了如何在运行 SQL Server 的计算机之间移动 Microsoft SQL Server 用户数据库和大多数常见的 S
- 在FF下,如果内容含有FLASH,FLASH不会被隐藏掉,做为变通,我在收缩完成之后,将生成的内容容器隐藏掉了。<!DOCTYPE h
- 1.由于数据库设计问题造成SQL数据库新增数据时超时症状:Microsoft OLE DB Provider for SQL Server
- 只是做笔记,没什么!! 代码如下:--创建测试表 CREATE TABLE [dbo].[Student]( [ID] [int
- 一个不错的网页拾色器也叫调色版,请看截图:当想要更多颜色时点击“其它颜色...”此时将调用系统自带的那个颜色选择框:注意:只有把〈scrip