ASP删除文件
set objfilesys=server.createobject("scripting.filesystemobject")
ss="文件名"
ss=server.mappath(ss)
if objfilesys.FILEExists(ss) then
objfilesys.deleteFILE ss
end if
我自己的运用示例: <% <% |
ASP删除目录
set objfilesys=server.createobject("scripting.filesystemobject")
ss="../EXAMDATA/" & idd
ss=server.mappath(ss)
if objfilesys.FOLDERExists(ss) then
objfilesys.deleteFOLDER ss
end if
VB删除目录及文件:
目录
Dim fso As FileSystemObject
Set fso = CreateObject("scripting.filesystemobject")
If fso.fileexists(strfile) Then
fso.DeleteFolder (strfile)
End If
Set fso = Nothing
文件:
Set fso = CreateObject("scripting.filesystemobject")
If fso.fileexists(strfile) Then
fso.deletefile (strfile)
End If
Set fso = Nothing
对硬盘上目录的遍历程序,文件名称bianli.asp
<%@ Language=VBScript %>
<%
function bianli(path)
dim fso 'fso对象
dim objFolder '文件夹对象
dim objSubFolders '子文件夹集合
dim objSubFolder '子文件夹对象
dim objFiles '文件集合
dim objFile '文件对象
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)'创建文件夹对象
set objSubFolders=objFolder.Subfolders'创建的子文件夹对象
for each objSubFolder in objSubFolders
nowpath=path + "/" + objSubFolder.name
Response.Write nowpath
set objFiles=objSubFolder.Files
for each objFile in objFiles
Response.Write "<br>---"
Response.Write objFile.name
next
Response.Write "<p>"
bianli(nowpath) '调用递归
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
bianli("d:") '调用bianli()函数,这里是遍历d:盘
%>
以上程序在win2000 server上运行通过。