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


猜你喜欢
- 最近在学习python网络编程这一块,在写简单的socket通信代码时,遇到了struct这个模块的使用,当时不太清楚这到底有和作用,后来查
- 1. datetime模块介绍1.1 datetime模块包含的类1.2 datetime模块中包含的常量2. datetime实例的方法案
- 系统环境:VC6 + Python-2.5.41、下载Python-2.5.4源码。2、解压,打开D:\Python-2.5.4\PC\VC
- 1 HSV上下限颜色的HSV上下限如下表:2 追踪单个颜色import cv2 as cvimport numpy as npcap = c
- go官方仅提供了database package,database package下有两个包sql,sql/driver。这两个包用来定义操
- 如何创建列表,或生成列表。这里介绍在python的基础知识里创建或转变或生成列表的一些方法。零个,一个或一系列数据用逗号隔开,放在方括号[
- ① 二维列表 根据给定的长和宽,以及初始值,返回一个二维列表:def initialize_2d_list(w, h, val=N
- 我们这里试输出一段字符:<%response.write Server.UrlEncode("织梦幻影")%>
- 1. fixture的声明我们使用@pytest.fixture()来声明fixture函数。fixture()即可无参数进行声明,也可以带
- 你知道(X)HTML中最多余的标签中是什么吗?在我看来就是这个<a>标签,不错,就是每个网站使用最多的超级链接标签<a&g
- Numpy是python常用的一个类库,在python的使用中及其常见,广泛用在矩阵的计算中,numpy对矩阵的操作与纯python比起来速
- 一、使用matplotlib显示图import matplotlib.pyplot as plt #plt用于显示图片import matp
- 不少小伙伴认为,直接去操作excel,比我们利用各种代码数据去处理,直接又简单,不那么花里胡哨,但是在代码上,处理数据,直接的软件操作是行不
- <% class menusPublic Title, ID, Image, TitleColor, Target, Backgrou
- 1 简介今天学长向大家介绍一个机器视觉项目基于机器视觉opencv的手势检测 手势识别 算法2 传统机器视觉的手势检测普通机器视觉手势检测的
- 本文实例讲述了django框架自定义模板标签(template tag)操作。分享给大家供大家参考,具体如下:django 提供了丰富的模板
- 一个小的解决方法分享:正常安装的情况下,你所需要的包都能在python文件夹下找到,找到你所需要的包 ,把它复制到Python35\Lib\
- 官方示例:uni-popup 弹出层 - DCloud 插件市场弹出层组件用于弹出一个覆盖到页面上的内容,使用场景如:底部弹出分
- Numpy中repeat函数使用Numpy是Python强大的数学计算库,和Scipy一起构建起Python科学计算生态。在本节下面我们重点
- 1.CNN卷积层通过nn.Conv2d可以设置卷积层,当然也有1d和3d。卷积层设置完毕,将设置好的输入数据,传给layer(),即可完成一