网站制作学习网ASP→正文:asp删除文件夹目录
字体:

asp删除文件夹目录

ASP 2010/3/23 17:50:12  点击:不统计


用asp写了一个函数,asp删除指定文件夹里面的所有内容,看看能看懂么?
<%@language="vbscript"%>
<%Option Explicit%>
<%
'asp获取当前物理路径
Dim foraspcnbase,foraspcndelpath,foraspcntemp,foraspcntemp_array
Dim foraspcnFos'网站制作学习网Foasp.cn
Set foraspcnFos = server.CreateObject("scripting.filesystemobject")
If not IsObject(foraspcnFos) Then response.write ("不支持FOS!,结束!"),response.End()
foraspcnbase = request.ServerVariables("APPL_PHYSICAL_PATH")'获取当前站点物理路径
'网站制作学习网原创,转载请注明http://www.forasp.cn
Function Foraspcn(path)
Dim path_folder,path_array,temp_path,filename,filename_array
If not foraspcnFos.FolderExists(path) Then
Foraspcn = False
Exit Function
End if
'如果是文件夹则开始遍历
Set path_folder = foraspcnFos.GetFolder(path)
set path_array = path_folder.Subfolders'网站制作学习网Foasp.cn
For each temp_path In path_array
If foraspcn(temp_path) Then
foraspcnFos.DeleteFolder(temp_path)
End if
Next
'删除目前所属文件夹内文件网站制作学习网Foasp.cn
Set filename = path_folder.files
For each filename_array In filename
foraspcnFos.DeleteFile path&"\"&filename_array.name
Next
Foraspcn = true
End Function
foraspcndelpath = foraspcnbase&"a"'删除根目录下的a文件夹以及里面所有内容
If foraspcn(foraspcndelpath) Then
response.write "删除成功"
Else
response.write "删除失败"
End if
%>
这个有个缺陷是不能删除自身所属文件夹(这理指的是a),再考虑写个新的asp删除文件夹
原文章%77w%77%2Ef%6F%72%61%73%70%2E%63n

·上一篇:asp获取当前物理路径 >>    ·下一篇:asp截取字符串重复间的内容 >>
推荐文章
最新文章