Browse file directories by file size using FSO and delete operations

Source: Internet
Author: User
Tags end file size visual studio
The following is an overview of the FSO's browse file directories by file size and how to delete them:

<%@ Language=vbscript%>
<%Server.ScriptTimeout=50000%>
<HTML>
<HEAD>
<meta name=\ "generator\" content=\ "Microsoft Visual Studio 6.0\" >
<meta http-equiv=\ "content-type\" content=\ "text/html; Charset=gb2312\ ">
</HEAD>
<BODY>
<%
function Judgepararegular (IntID)
If intid<>\ "\" and IsNumeric (IntID) Then
Judgepararegular=intid
Else
Response.Write \ "Input Error!" \"
Response.End
End If
End Function
Intfilesize=judgepararegular (Request.QueryString (\ "Intfilesize\"))
Strpath=request.querystring (\ "Strpath\")
If InStr (strpath,\ ": \") =0 then Strpath=server. MapPath (strpath)
%>
<%
function Deletefiles (path)
On Error Resume Next
Set fs=server.createobject (\ "Scripting.filesystemobject\")
If Fs. FileExists (PATH) Then
Fs. DeleteFile Path,true
Response.Write \ "successfully deleted \" &path
Else
Response.Write \ "File does not exist!\"
End If
Set fs=nothing
If Err.number<>0 then Response.Write err.number
End Function
Strfile=request (\ "Strfile\")
If request (\ "strfile\") <>\ "\" Then
Deletefiles strfile
End If

%>

<%
function Listfolderfiles (Strpath,intfilesize,intflag)
Stroriginpath= Request.ServerVariables (\ "script_name\") & \ "? strpath=\" &request.querystring (\ "StrPath\") & \ "&intfilesize=\" &request.querystring (\ "Intfilesize\")
If strpath<>\ "\" Then
If Intflag=0 Then
Intflag=intflag+1
End If
Set objfs=server.createobject (\ "Scripting.filesystemobject\")
Set Objfdir=objfs.getfolder (strpath)
Strparentpath= Objfs.getparentfoldername (strpath)
For each strsubfiles in Objfdir.files
If Strsubfiles.size/(1024^2) >=intfilesize Then
Response.Write \ "<tr>\" & vbCrLf
Response.Write \ "<td>\" & Replace (Strnulltran (strsubfiles), Strnulltran (strsubfiles.name), \ "<b>\" &strnulltran (strsubfiles.name) &\ "</b>\") & \ "</td>\" & vbCrLf
Response.Write \ "<td>\" & Strnulltran (FormatNumber (Strsubfiles.size/(1024^2), 2)) &\ "MB</TD>\" & vbCrLf
Response.Write \ "<td>\" & Strnulltran (strsubfiles.type) & \ "</td>\" & vbCrLf
Response.Write \ "<td>\" & Strnulltran (strsubfiles.datelastmodified) & \ "</td>\" & vbCrLf
Response.Write \ "<td><a href=\ '" & Stroriginpath & \ "&strfile=\" &strnulltran (strSubFiles) &\ "\ ' ></a></td>\" & vbCrLf
Response.Write \ "</tr>\" & vbCrLf
Intflag=intflag+strsubfiles.size
End If
Next
For each strsubfolders in Objfdir.subfolders
If Intflag=0 then intflag=1
Listfolderfiles Strsubfolders,intfilesize,intflag
Next
Else
Response.Write \ "&LT;TR&GT;&LT;TD colspan=5> input Error! </td></tr>\ "
End If
Listfolderfiles=intflag
End Function
function Strnulltran (str)
If IsNull (str) or str=\ "\" Then
Strnulltran=\ "\"
Else
Strnulltran=str
End If
End Function
Response.Write \ "<table width=100% border=1 cellspacing=1 cellpadding=1>\" & vbCrLf
Response.Write \ "<tr>\" & vbCrLf
Response.Write \ "<TD> filename and path </td>\" & vbCrLf
Response.Write \ "<td align=center> size </td>\" & vbCrLf
Response.Write \ "&LT;TD align=center> category </td>\" & vbCrLf
Response.Write \ "<td align=center> modification Time </td>\" & vbCrLf
Response.Write \ "<td align=center> delete </td>\" & vbCrLf
Response.Write \ "</tr>\" & vbCrLf
Intflag=listfolderfiles (Strpath,cdbl (intfilesize), 0)
Response.Write \ "<tr><td align=right> total: </td><td colspan=4>\" &formatNumber (intFlag-1 )/(1024^2), 2 &\ "mb</td></tr>\" & vbCrLf
Response.Write \ "</table>\" & vbCrLf
%>
</BODY>
</HTML>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.