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

下面介绍FSO按文件大小浏览文件目录并进行删除操作的方法:

<%@ 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=\"0741912543038824.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>
 

时间: 2024-08-18 03:14:39

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

把这个组成文件就行了!,建议斑竹加精华!关键字:使用FSO按文件大小浏览文件目录并进行删除操作

fso|关键字|精华 <%@ Language=VBScript %><%Server.ScriptTimeout=50000%><HTML><HEAD><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"><meta http-equiv="Content-Type" content="text/htm

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

<%@ Language=VBScript %> <%Server.ScriptTimeout=50000%> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <meta http-equiv="Content-Type" content="text/html; cha

apache 禁止用户浏览文件目录

我们可以通过修改Apache配置文件httpd.conf来实现禁止列出目录/文件列表,方法如下: 1.打开apache%C5%E4%D6%C3/" target="_blank">apache配置文件httpd.conf 2.找到  代码如下 复制代码 <Directory /> Options Indexes AllowOverride None Order allow,deny Allow from all </Directory> 只需要修

asp结合fso实现文件或文件夹创建删除等操作的函数_应用技巧

'////////////////////////////////////////////////FSO操作///////////////////////////////////// '判断文件夹是否存在 Function FolderExits(Folder) Folder=Server.Mappath(Folder) Set FSO= Server.CreateObject("Scripting.FileSystemObject") IF FSO.FolderExists(Fold

asp结合fso实现文件或文件夹创建删除等操作的函数

'////////////////////////////////////////////////FSO操作///////////////////////////////////// '判断文件夹是否存在 Function FolderExits(Folder) Folder=Server.Mappath(Folder) Set FSO= Server.CreateObject("Scripting.FileSystemObject") IF FSO.FolderExists(Fold

ASP入门教程-文件操作

文件操作主要包括复制.移动和删除文件,检查文件是否存在以及获取文件的属性.完成这些操作可以使用 FileSystemObject 或 File 对象的方法. 一.使用 FileSystemObject 对象的相应方法进行文件操作 1.复制文件:将一个或多个文件复制到其他位置上,语法格式如下: <% fso.CopyFile source,destination[,overwrite] %> * fso :指定 FileSystemObject 对象的名称: * source :表示指定文件的字

500种病毒变种集体攻击电脑安全系统

病毒发作症状 1.生成很多8位数字或字母随机命名的病毒程序文件,并在电脑开机时自动运行. 2.绑架安全软件,中毒后会发现几乎所有杀毒软件,系统管理工具,反间谍软件不能正常启动. 3.不能正常显示隐藏文件,其目的是更好地隐藏自身不被发现. 4.禁用windows自动更新和Windows防火墙,这样木马下载器工作时,就不会有任何提示窗口弹出来. 5.破坏系统安全模式,使得用户不能启动系统到安全模式来维护和修复. 6.当前活动窗口中有杀毒.安全.社区相关的关键字时,病毒会关闭这些窗口.假如你想通过浏览

FSO操作文件系统_数据库相关

实现功能: 文件(夹)目录列表 提供了查阅目录下面的文件和文件夹 文件 写,创,删 提供了编辑,删除文件(文件夹)的操作 创建文件夹/文件 针对创建文件夹(文件)而设置. 上传文件 您可以模拟FTP上传,文件大小,类型不受限制.  有兴趣的自己体验,出现任何问题我均不承担任何后果,在此说,我没多少时间上网,经常也顾不过来,是看到最近经常有人问这方面的问题,就发上来,希望有所帮助. upfso.asp //控制上传的文件 复制代码 代码如下: <!--#include file="uploa

提高Windows Server 2003下FSO的安全性

FSO(http://www.aliyun.com/zixun/aggregation/19352.html">FileSystemObject)是微软ASP的一个对文件操作的控件,该控件可以对服务器进行读取.新建.修改.删除目录以及文件的操作.是ASP编程中非常有用的一个控件.但是因为权限控制的问题,很多虚拟主机服务器的FSO反而成为这台服务器的一个公开的后门,因为客户可以在自己的ASP网页里面直接就对该控件编程,从而控制该服务器甚至删除服务器上的文件.因此不少业界的虚拟主机提供商都干脆