asp下利用fso实现文件夹或文件移动改名等操作函数
程序员文章站
2022-05-28 16:39:04
asp利用fso实现文件的移动function movefiles(sfolder,dfolder) on&nbs...
asp利用fso实现文件的移动
function movefiles(sfolder,dfolder)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sfolder)) and fso.folderexists(server.mappath(dfolder)) then
fso.copyfolder server.mappath(sfolder),server.mappath(dfolder)
movefiles = true
else
movefiles = false
set fso = nothing
call alertbox("系统没有找到指定的路径[" & sfolder & "]!",2)
end if
set fso = nothing
end function
asp修改文件夹名称
function renamefolder(sfolder,dfolder)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sfolder)) then
fso.movefolder server.mappath(sfolder),server.mappath(dfolder)
renamefolder = true
else
renamefolder = false
set fso = nothing
call alertbox("系统没有找到指定的路径[" & sfolder & "]!",2)
end if
set fso = nothing
end function
asp检查文件夹是否存在
function checkfolder(spath)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(spath)) then
checkfolder = true
else
checkfolder = false
end if
set fso = nothing
end function
asp检查文件是否存在
function checkfile(spath)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(server.mappath(spath)) then
checkfile = true
else
checkfile = false
end if
set fso = nothing
end function
asp创建文件夹
function createdir(spath)
dim fso,patharr,i,path_level,pathtmp,cpath
on error resume next
spath = replace(spath,"\","/")
set fso = server.createobject("scripting.filesystemobject")
patharr = split(spath,"/")
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 fso.folderexists(cpath) then fso.createfolder(cpath)
next
set fso = nothing
if err.number <> 0 then
err.clear
createdir = false
else
createdir = true
end if
end function
删除文件夹,这里是删除系统中栏目的文件夹
function delclassfolder(spath)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(spath)) then
fso.deletefolder(server.mappath(spath))
end if
set fso = nothing
end function
删除新闻内容文件
function delnewsfile(spath,filename)
on error resume next
dim fso,temparr,cpath,epath,i:i = 0
set fso = server.createobject("scripting.filesystemobject")
spath = spath & filename & site_extname
if fso.fileexists(server.mappath(spath)) then
fso.deletefile(server.mappath(spath))
while(i <> -1)
i = i + 1
epath = replace(spath,filename & ".",filename & "_" & i + 1 & ".")
if fso.fileexists(server.mappath(epath)) then
fso.deletefile(server.mappath(epath))
else
i = -1
end if
wend
end if
end function
function movefiles(sfolder,dfolder)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sfolder)) and fso.folderexists(server.mappath(dfolder)) then
fso.copyfolder server.mappath(sfolder),server.mappath(dfolder)
movefiles = true
else
movefiles = false
set fso = nothing
call alertbox("系统没有找到指定的路径[" & sfolder & "]!",2)
end if
set fso = nothing
end function
asp修改文件夹名称
function renamefolder(sfolder,dfolder)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sfolder)) then
fso.movefolder server.mappath(sfolder),server.mappath(dfolder)
renamefolder = true
else
renamefolder = false
set fso = nothing
call alertbox("系统没有找到指定的路径[" & sfolder & "]!",2)
end if
set fso = nothing
end function
asp检查文件夹是否存在
function checkfolder(spath)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(spath)) then
checkfolder = true
else
checkfolder = false
end if
set fso = nothing
end function
asp检查文件是否存在
function checkfile(spath)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(server.mappath(spath)) then
checkfile = true
else
checkfile = false
end if
set fso = nothing
end function
asp创建文件夹
function createdir(spath)
dim fso,patharr,i,path_level,pathtmp,cpath
on error resume next
spath = replace(spath,"\","/")
set fso = server.createobject("scripting.filesystemobject")
patharr = split(spath,"/")
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 fso.folderexists(cpath) then fso.createfolder(cpath)
next
set fso = nothing
if err.number <> 0 then
err.clear
createdir = false
else
createdir = true
end if
end function
删除文件夹,这里是删除系统中栏目的文件夹
function delclassfolder(spath)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(spath)) then
fso.deletefolder(server.mappath(spath))
end if
set fso = nothing
end function
删除新闻内容文件
function delnewsfile(spath,filename)
on error resume next
dim fso,temparr,cpath,epath,i:i = 0
set fso = server.createobject("scripting.filesystemobject")
spath = spath & filename & site_extname
if fso.fileexists(server.mappath(spath)) then
fso.deletefile(server.mappath(spath))
while(i <> -1)
i = i + 1
epath = replace(spath,filename & ".",filename & "_" & i + 1 & ".")
if fso.fileexists(server.mappath(epath)) then
fso.deletefile(server.mappath(epath))
else
i = -1
end if
wend
end if
end function
下一篇: asp实现dig功能的js代码