常用目录的操作函数ASP

下面是一些常用的利用FSO函数实现对文件目录的一些操作(用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

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

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 delfolder(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

原载: http://www.auuo.com
版权说明:原创文章欢迎转载,但转载请务必以超链接标明文章原始出处、作者信息和本声明。否则必追究法律责任

联系我们

QQ:51193930(Ahoo)
MSN:auuocx@hotmail.com
网址:http://www.auuo.com
地址:慈溪天九商务中心525室
电话:189-0662-0882

我们的优势
拥有优秀的网站设计师与程序工程师,精通各种一流的图形设计软件,如Photoshop、Freehand CorlDraw、Flash、Dreamweaver、Fireworks等等制作网页和平面设计图。以及使用C语言、C#、ASP.NET框架、asp、php等语言为您开发项目,我们为您准备了最专业的技术服务。为您开发的网站精致实用,代码清晰,保证您的网站安全可靠修改方便,最重要的是符合市场需求,并随时为客户解决各种技术问题。

我们正在努力开拓...

baidu

互联网 本网站