asp常用文件与文件夹操作函数[网站编程]
本文“asp常用文件与文件夹操作函数[网站编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
下面是我汇集了大家在开辟中常用的asp文件与文件夹操作函数,有文件成立,删除以及文件夹删除,成立等功效.
<%
'文件操作函数:写文件
private sub writefile(filename,text)
dim fso,file
set fso = createobject("scripting.filesystemobject")
set file = fso.createtextfile(filename, true)
file.write(text)
file.close
set file = nothing
set fso = nothing
end sub
'文件操作函数:读文件
function readfile(filename)
dim fso,file
set fso = createobject("scripting.filesystemobject")
set file = fso.opentextfile(filename, 1)
readfile = file.readall()
file.close
set file = nothing
set fso = nothing
end function
'测试文件夹能否存在
function checkfolder(folder)
dim fso,exists
set fso = createobject("scripting.filesystemobject")
checkfolder = fso.folderexists(folder)
set fso = nothing
end function
'成立文件夹
private sub createfolder(folder)
dim fso
set fso = createobject("scripting.filesystemobject")
fso.createfolder(folder)
set fso = nothing
end sub
'删除文件夹
private sub deletefolder(folder)
dim fso
set fso = createobject("scripting.filesystemobject")
fso.deletefolder(server.mappath(folder))
set fso = nothing
end sub
'删除文件
private sub deletefile(fname)
set fso = createobject("scripting.filesystemobject")
if fso.fileexists(server.mappath(fname)) then
set f = fso.getfile(server.mappath(fname))
f.delete()
set f = nothing
end if
set fso = nothing
end sub
'测试文件夹能否存在,不存在则成立
private sub checksavepath(filesavepath)
p_tmp = split(filesavepath,"/")
path = ""
for i = 0 to ubound(p_tmp)
if p_tmp(i) = "" then
path = path & "/"
else
path = path & p_tmp(i) & "/"
if not checkfolder(server.mappath(path)) then call createfolder(server.mappath(path))
end if
next
end sub
%>
以上是“asp常用文件与文件夹操作函数[网站编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |
- ·上一篇文章:一款完好asp考证码程序
- ·下一篇文章:asp开辟中常用函数
- ·中查找“asp常用文件与文件夹操作函数”更多相关内容
- ·中查找“asp常用文件与文件夹操作函数”更多相关内容