加入收藏
联系我们
关于我们
 您现在的位置: 亿聪 >> 网络学院 >> 网络编程 >> ASP >> 正文  
  使用FSO按文件大小浏览文件目录并进行删除操作         ★★★
使用FSO按文件大小浏览文件目录并进行删除操作
[ 作者:刘子良    转贴自:开发者俱乐部    点击数:2962    更新时间:2003/8/28    文章录入:亿聪 ]
<%@ 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

%>

<%
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='images/delete.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>

  • 上一篇文章: FSO的一些特殊功能

  • 下一篇文章: 随机生成文件名的函数
  • 发表评论】【告诉好友】【打印此文】【关闭窗口
     最新5篇热点文章
  • Knoppix 4.0.2 免硬盘免安…[15084]

  • 通过ASP记录进行分页[19273]

  • ASP开发准则[11225]

  • ASP组件指南[11196]

  • ASP指南[11210]

  •  
     最新5篇推荐文章
  • Knoppix 4.0.2 免硬盘免安…[15084]

  • 如何让Win 2003系统更加安…[12452]

  • Nero超刻简明教程[33940]

  • PS商业实战-来杯茶,行吗?…[7080]

  • ASP深度揭密(下)[12206]

  •  
     相 关 文 章
  • 构建免受FSO威胁虚拟主机[4644]

  • FSO的一些特殊功能[2999]


  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
        没有任何评论
    设为首页 | 加入收藏 | 关于我们 | 联系我们 | 友情链接 | 版权声明 | 管理登录
    Copyright © 2000-2022 Yicong.com.All Rights Reserved.
    亿聪 版权所有 E-mail: