简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

asp删除文件夹目录

来源:易贤网   阅读:2680 次  日期:2014-08-26 09:52:11

温馨提示:易贤网小编为您整理了“asp删除文件夹目录”,方便广大网友查阅!

用asp写了一个函数,asp删除指定文件夹里面的所有内容,看看能看懂么?

<%@language="vbscript"%>

<%Option Explicit%>

<%

'asp获取当前物理路径

Dim foraspcnbase,foraspcndelpath,foraspcntemp,foraspcntemp_array

Dim foraspcnFos'

Set foraspcnFos = server.CreateObject("scripting.filesystemobject")

If not IsObject(foraspcnFos) Then response.write ("不支持FOS!,结束!"),response.End()

foraspcnbase = request.ServerVariables("APPL_PHYSICAL_PATH")'获取当前站点物理路径

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'

For each temp_path In path_array

If foraspcn(temp_path) Then

foraspcnFos.DeleteFolder(temp_path)

End if

Next

'删除目前所属文件夹内文件

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删除文件夹

更多信息请查看IT技术专栏

更多信息请查看网络编程
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:asp截取字符串重复间的内容
下一篇:asp获取当前物理路径
易贤网手机网站地址:asp删除文件夹目录
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!