使用FSO按文件大小浏览文件目录并进行删除操作,使用FSO按文件大小浏览文件目录并进行删除操作
【 tulaoshi.com - ASP 】
<%@ Language=VBScript %%
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/asp/)<%
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)&"'<img align=absmiddle border=0 src="http://img.jcwcn.com/attachment/portal/chinazcj/2005-11/18/05111822392183263.gif"</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 "<tr<td colspan=5输入错误!</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文件名及路径</TD" & vbcrlf
Response.Write "<TD align=center大小</TD" & vbcrlf
Response.Write "<TD align=center类别</TD" & vbcrlf
Response.Write "<TD align=center修改时间</TD" & vbcrlf
Response.Write "<TD align=center删除</TD" & vbcrlf
Response.Write "</TR" & vbcrlf
intFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)
Response.Write "<tr<td align=right总计:</td<td colspan=4"&formatNumber((intFlag-1)/(1024^2),2) &" MB</td</tr" & vbcrlf
Response.Write "</TABLE" & vbcrlf
%
</BODY
</HTML
来源:http://www.tulaoshi.com/n/20160129/1510987.html
看过《使用FSO按文件大小浏览文件目录并进行删除操作》的人还看了以下文章 更多>>