上一篇:fso的一些特殊功能 >>
使用FSO按文件大小浏览文件目录并进行删除操作
<%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>
下一篇:NAV导致IIS调用FSO失败的解决方法 >>
相关文章:
- · 文本搜索
- · FileSystemObject处理文件
- · 设计 FileSystemObject
- · 处理驱动器和文件夹
- · 通过数组给您的文件排序
- · 用ASP做一个TOP COOL的站内搜索
- · 怎样读取一个文本文件的内容?
- · 在线用表单建立文件夹
- · filesystemobject组件的用法示例
- · ASP中文本文件与数据库文件的数据交换(FSO)
- · 列出指定目录下的所有文件和目录
- · 读取目录下的所有文件(包括子目录下的所有文件)
- · ASP中FSO的神奇功能 - FSO不能做到的
- · ASP中FSO的神奇功能 - 用FSO进行内容管理
- · ASP中FSO的神奇功能 - 使用FSO进行搜索
- · ASP中FSO的神奇功能 - 权限许可
- · ASP中FSO的神奇功能 - 文件读取
- · ASP中FSO的神奇功能 - 写文件
- · ASP中FSO的神奇功能 - 简介
- · 读取目录下的文件得到一个数组
- · 奇妙的文件系统对象组件
- · ASP.NET2.0导航功能之配置会员和角色
- · C#+ASP.NET开发基于Web的RSS阅读器
- · 在ASP.NET程序中实现语音合成
- · 在Apache上调试ASP.NET 1.1/2.0代码
- · ASP.NET初学:建立ASP.NET开发平台
- · 用ASP.Net和Access编写留言本
- · .net中发mail到hotmail中乱码问题的解决
- · ASP.Net应用程序的多进程模型
- · 用 ASP.NET 2.0 改进的 ViewState 加快网站速度
- · 在ASP.NET中使用Session常见问题集锦
- · ASP.NET文章管理系统:系统分析与设计
- · asp.net开发常用技巧收集
- · ASP.NET 2.0运行时简要分析
- · 在IIS6.0下ASP .NET 的版本冲突问题
- · ASP.NET:目录的遍历
- · ASP.NET:目录创建和删除
- · ASP.Net:基于窗体的身份验证
