手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp下利用fso实现文件夹或文件移动改名等操作函数
asp下利用fso实现文件夹或文件移动改名等操作函数
摘要:asp利用fso实现文件的移动functionmovefiles(sFolder,dFolder)onerrorresumenextdimf...

asp利用fso实现文件的移动

functionmovefiles(sFolder,dFolder)

onerrorresumenext

dimfso

setfso=server.createobject("scripting.filesystemobject")

iffso.folderexists(server.mappath(sFolder))andfso.folderexists(server.mappath(dFolder))then

fso.copyfolderserver.mappath(sFolder),server.mappath(dFolder)

movefiles=true

else

movefiles=false

setfso=nothing

callalertbox("系统没有找到指定的路径["&sFolder&"]!",2)

endif

setfso=nothing

endfunction

asp修改文件夹名称

functionrenamefolder(sFolder,dFolder)

onerrorresumenext

dimfso

setfso=server.createobject("scripting.filesystemobject")

iffso.folderexists(server.mappath(sFolder))then

fso.movefolderserver.mappath(sFolder),server.mappath(dFolder)

renamefolder=true

else

renamefolder=false

setfso=nothing

callalertbox("系统没有找到指定的路径["&sFolder&"]!",2)

endif

setfso=nothing

endfunction

asp检查文件夹是否存在

functioncheckfolder(sPATH)

onerrorresumenext

dimfso

setfso=server.createobject("scripting.filesystemobject")

iffso.folderexists(server.mappath(sPATH))then

checkfolder=true

else

checkfolder=false

endif

setfso=nothing

endfunction

asp检查文件是否存在

functioncheckfile(sPATH)

onerrorresumenext

dimfso

setfso=server.createobject("scripting.filesystemobject")

iffso.fileexists(server.mappath(sPATH))then

checkfile=true

else

checkfile=false

endif

setfso=nothing

endfunction

asp创建文件夹

functioncreatedir(sPATH)

dimfso,pathArr,i,path_Level,pathTmp,cPATH

onerrorresumenext

sPATH=replace(sPATH,"","/")

setfso=server.createobject("scripting.filesystemobject")

pathArr=split(sPATH,"/")

path_Level=ubound(pathArr)

fori=0topath_Level

ifi=0thenpathTmp=pathArr(0)&"/"elsepathTmp=pathTmp&pathArr(i)&"/"

cPATH=left(pathTmp,len(pathTmp)-1)

ifnotfso.folderexists(cPATH)thenfso.createfolder(cPATH)

next

setfso=nothing

iferr.number<>0then

err.clear

createdir=false

else

createdir=true

endif

endfunction

删除文件夹,这里是删除系统中栏目的文件夹

functiondelclassfolder(sPATH)

onerrorresumenext

dimfso

setfso=server.createobject("scripting.filesystemobject")

iffso.folderexists(server.mappath(sPATH))then

fso.deletefolder(server.mappath(sPATH))

endif

setfso=nothing

endfunction

删除新闻内容文件

functiondelnewsfile(sPATH,filename)

onerrorresumenext

dimfso,tempArr,cPATH,ePATH,i:i=0

setfso=server.createobject("scripting.filesystemobject")

sPATH=sPATH&filename&site_extname

iffso.fileexists(server.mappath(sPATH))then

fso.deletefile(server.mappath(sPATH))

while(i<>-1)

i=i+1

ePATH=replace(sPATH,filename&".",filename&"_"&i+1&".")

iffso.fileexists(server.mappath(ePATH))then

fso.deletefile(server.mappath(ePATH))

else

i=-1

endif

wend

endif

endfunction

【asp下利用fso实现文件夹或文件移动改名等操作函数】相关文章:

asp 中常用的文件处理函数

ASP中生成文本文件的两种方式

asp中向文本框输出数据原样式的函数

用ASP实现远程批量文件改名

用ASP实现对MP3曲目信息的操作

一个可以自动创建多级目录的函数

用ASP实现距指定日期的倒记时程序源码

利用ASPUPLOAD,ASPJPEG实现图片上传自动生成缩略图及加上水印

asp中FSO复制文件代码

ASP得到文件的大小类型最后修改时间

精品推荐
分类导航