<p>使用FSO按文件大小浏览文件目录并进行删除</p>
<p><%@ Language=VBScript %><br />
<%Server.ScriptTimeout=50000%><br />
<HTML><br />
<HEAD><br />
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"><br />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><br />
</HEAD><br />
<BODY><br />
<%<br />
function JudgeParaRegular(intID)<br />
if intID<>"" and isnumeric(intID) then<br />
JudgeParaRegular=intId<br />
else<br />
Response.Write "输入错误!" <br />
Response.End <br />
end if<br />
end function<br />
intFileSize=JudgeParaRegular(Request.QueryString("intFileSize"))<br />
strPath=Request.QueryString("strPath")<br />
if instr(strPath,":")=0 then strPath=server.MapPath(strPath)<br />
%><br />
<%<br />
function deletefiles(path)<br />
on error resume next<br />
Set fs=Server.CreateObject("Scripting.FileSystemObject")<br />
if fs.FileExists(path) then<br />
fs.DeleteFile path,True<br />
response.write "成功删除"&path<br />
else<br />
response.write "文件不存在!"<br />
end if<br />
Set fs=nothing<br />
if Err.number<>0 then Response.Write Err.number <br />
end function<br />
strFile=request("strFile")<br />
if request("strFile")<>"" then<br />
deletefiles strFile<br />
end if<br />
%><br />
<%<br />
function ListFolderFiles(strPath,intFileSize,intFlag)<br />
strOriginPath= Request.ServerVariables("Script_Name")& "?strPath=" &Request.QueryString("strPath") & "&intFileSize="&Request.QueryString("intFileSize")<br />
if strPath<>"" then<br />
if intFlag=0 then<br />
intFlag=intFlag+1<br />
end if <br />
Set objFs=Server.CreateObject("Scripting.FileSystemObject")<br />
Set objFdir=objFs.GetFolder(strPath)<br />
strParentPath= objFs.GetParentFolderName(strPath)<br />
for each strSubFiles in objFdir.files<br />
if strSubFiles.size /(1024^2)>=intFileSize then<br />
Response.Write "<TR>" & vbcrlf<br />
Response.Write "<TD>" & replace(strNullTran(strSubFiles),strNullTran(strSubFiles.Name),"<b>"&strNullTran(strSubFiles.Name)&"</b>") & "</TD>" & vbcrlf<br />
Response.Write "<TD>"& strNullTran(FormatNumber(strSubFiles.size /(1024^2),2)) &" MB</TD>" & vbcrlf<br />
Response.Write "<TD>" & strNullTran(strSubFiles.type) & "</TD>" & vbcrlf<br />
Response.Write "<TD>" & strNullTran(strSubFiles.datelastmodified) & "</TD>" & vbcrlf<br />
Response.Write "<TD><A HREF='"& strOriginPath & "&strFile="&strNullTran(strSubFiles)&"'><img align=absmiddle border=0 src='http://www.163design.net/a/o/images/delete.gif'></A></TD>" & vbcrlf<br />
Response.Write "</TR>" & vbcrlf<br />
intFlag=intFlag+strSubFiles.size<br />
end if<br />
next<br />
for each strSubFolders in objFdir.SubFolders<br />
if intFlag=0 then intFlag=1<br />
ListFolderFiles strSubFolders,intFileSize,intFlag<br />
next<br />
else<br />
Response.Write "<tr><td colspan=5>输入错误!</td></tr>"<br />
end if<br />
ListFolderFiles=intFlag<br />
end function<br />
function strNullTran(str)<br />
if isnull(str) or str="" then<br />
strNullTran=" "<br />
else<br />
strNullTran=str<br />
end if<br />
end function <br />
Response.Write "<TABLE WIDTH=100% BORDER=1 CELLSPACING=1 CELLPADDING=1>" & vbcrlf<br />
Response.Write "<TR>" & vbcrlf<br />
Response.Write "<TD>文件名及路径</TD>" & vbcrlf<br />
Response.Write "<TD align=center>大小</TD>" & vbcrlf<br />
Response.Write "<TD align=center>类别</TD>" & vbcrlf<br />
Response.Write "<TD align=center>修改时间</TD>" & vbcrlf<br />
Response.Write "<TD align=center>删除</TD>" & vbcrlf<br />
Response.Write "</TR>" & vbcrlf<br />
intFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)<br />
Response.Write "<tr><td align=right>总计:</td><td colspan=4>"&formatNumber((intFlag-1)/(1024^2),2) &" MB</td></tr>" & vbcrlf<br />
Response.Write "</TABLE>" & vbcrlf<br />
%><br />
</BODY><br />
</HTML></p>