手机
当前位置:查字典教程网 >编程开发 >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中正则表达式过滤html代码函数

ASP中利用execute实现动态包含文件的方法

ASP实例学习:随机生成文件名的函数

在ASP中利用ADO显示Excel文件内容的函数

asp下同一空间多绑多哥域名的方法

FileSystem对象常用的文件操作函数有哪些?

asp中FSO复制文件代码

精品推荐
分类导航