fso删除文件:使用FSO按文件大小浏览文件目录并进行删除操作来源: 发布时间:星期四, 2008年9月25日 浏览:108次 评论:0
<%@ Language=VBScript %>
<%Server.ScriptTimeout=50000%> <HTML> <HEAD> <META NAME=\"GENERATOR\" Content=\"Microsoft Visual Studio 6.0\"> <meta http-equiv=\"Content-Type\" content=\"text/html; char=gb2312\"> </HEAD> <BODY> <% function JudgeParaRegular(ID) ID<>\"\" and isnumeric(ID) then JudgeParaRegular=Id Response.Write \"输入!\" Response.End end end function FileSize=JudgeParaRegular(Request.QueryString(\"FileSize\")) strPath=Request.QueryString(\"strPath\") instr(strPath,\":\")=0 then strPath=server.MapPath(strPath) %> <% function deletefiles(path) on error resume next Set fs=Server.CreateObject(\"Scripting.FileObject\") fs.FileExists(path) then fs.DeleteFile path,True response.write \"成功删除\"&path response.write \"文件不存在!\" end Set fs=nothing Err.number<>0 then Response.Write Err.number end function strFile=request(\"strFile\") request(\"strFile\")<>\"\" then deletefiles strFile end %> <% function ListFolderFiles(strPath,FileSize,Flag) strOriginPath= Request.ServerVariables(\"Script_Name\")& \"?strPath=\" &Request.QueryString(\"strPath\") & \"&FileSize=\"&Request.QueryString(\"FileSize\") strPath<>\"\" then Flag=0 then Flag=Flag+1 end Set objFs=Server.CreateObject(\"Scripting.FileObject\") Set objFdir=objFs.GetFolder(strPath) strParentPath= objFs.GetParentFolderName(strPath) for each strSubFiles in objFdir.files strSubFiles.size /(1024^2)>=FileSize 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.datelastmodied) & \"</TD>\" & vbcrlf Response.Write \"<TD><A HREF=\'\"& strOriginPath & \"&strFile=\"&strNullTran(strSubFiles)&\"\'><img align=absmiddle border=0 src=\"http://127.0.0.1/Files/BeyondPic/2007-4/19/0741912543038824.g\"></A></TD>\" & vbcrlf Response.Write \"</TR>\" & vbcrlf Flag=Flag+strSubFiles.size end next for each strSubFolders in objFdir.SubFolders Flag=0 then Flag=1 ListFolderFiles strSubFolders,FileSize,Flag next Response.Write \"<tr><td colspan=5>输入!</td></tr>\" end ListFolderFiles=Flag end function function strNullTran(str) isnull(str) or str=\"\" then strNullTran=\" \" strNullTran=str end 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 Flag=ListFolderFiles(strPath,CDbl(FileSize),0) Response.Write \"<tr><td align=right>总计:</td><td colspan=4>\"&formatNumber((Flag-1)/(1024^2),2) &\" MB</td></tr>\" & vbcrlf Response.Write \"</TABLE>\" & vbcrlf %> </BODY> </HTML> 0
相关文章读者评论发表评论 |