使用FSO按文件大小浏览文件目录并进行删除操作

2016-01-29 20:18 1 1 收藏

使用FSO按文件大小浏览文件目录并进行删除操作,使用FSO按文件大小浏览文件目录并进行删除操作

【 tulaoshi.com - ASP 】

<%@ 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 "输入错误!"
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 "成功删除"&path
else
response.write "文件不存在!"
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

%

(本文来源于图老师网站,更多请访问https://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

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

来源:https://www.tulaoshi.com/n/20160129/1510987.html

延伸阅读
标签: ASP
      '**************************************     ' Name: File / Directory Viewer     ' Description:This Will Display All The     '     Files, File Size and file date of every     ' ...
标签: Web开发
尽管对于现如今的带宽来说,网页文件那仅以K来算的大小实在是微不足道,但如何将这以K来计算的网页文件精简到最小还是网页设计师们所应该考虑的问题之一。 众所周之,在不影响整个网页构架与功能的情况下,网页文件越小越好,因为更小的网页文件有利于浏览器对网页的解释时间缩到更短,自然访客也就不用面临等待网页缓慢呈现的烦躁了...
标签: 服务器
Linux中的文件与目录操作利器mv命令使用解析   mv 命令是一个与cp类似的命令,但是它并非创建文件或目录的复制品/副本。不管你在使用什么版本的Linux系统,mv 都默认安装在你的Linux系统上了。 用法:mv [选项]... [-T] 源文件 目标文件 或:mv [选项]... 源文件... 目录 或:mv [选项]... -t 目录 源文件... 将...
标签: 电脑入门
在进行Linux系统操作的时候,有时会遇到压缩文件过大的情况,解压不方便,如果只需要其中的某个文件,而又想知道该文件有多大的话,该怎么办呢?下面图老师小编就给大家介绍下Linux下在不解压tar.gz文件的情况下如何查看其中文件的大小,一起来学习下吧。 如何不解压tar.gz文件查看其中的文件大小 tar tvf my_file.tar.gz 输出形如: -r...
标签: Web开发
? //删除目录 //本程序由wm_chief原创,如要转载,请注明作者与

经验教程

445

收藏

47
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部