如何用asp删除站点下的文件

来源:百度知道 编辑:UC知道 时间:2024/06/08 13:47:18
如何用asp删除站点某一目录下<font color="red">小等于1K</font>的文件,懂程序的高手先谢了。分数要多少,成功后自己开。
一楼的做法还是不行,会出错,自己先测试下,二楼把整个目录给删了。我要的是把站点html根目录下小等于1k的.htm文件删除。

帮你试了快一个小时了~!!!!!!!
如果这次的分没有给我就太对不起我了~~~~~~~~~~
你要用的时候要注意路径的正确写法!!!!!!!

<%
'确定浏览目录
Dim WwwRoot
WwwRoot = "taitai/" //这个目录一定要写对哦,TAITAI是我根目录的一个文件夹!!!

Function FsoList(Byval Path)
set Fso=createobject("Scripting.filesystemobject")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
set folder = fso.getfolder(Server.MapPath(Path))
set fc = folder.files '获得记录总数

For each f in fc
if (Round(F.Size/1024,0))<=1 then objFSO.DeleteFile Server.MapPath(WwwRoot+F.Name) End If
Next
Set Fso=Nothing
Set objFSO = Nothing
End Function

'调用函数
Response.Write FsoList(WwwRoot)
%>

'调用
path=Server.MapPath("***.htm")
delfile(path)

'删除文件
Function delfile(path)
'On Error Resume Next
If IsExists(path)=True Then
set fso = server