<p>使用FSO按文件大小浏览文件目录并进行删除</p> <p>&lt;%@ Language=VBScript %&gt;<br /> &lt;%Server.ScriptTimeout=50000%&gt;<br /> &lt;HTML&gt;<br /> &lt;HEAD&gt;<br /> &lt;META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;&gt;<br /> &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot;&gt;<br /> &lt;/HEAD&gt;<br /> &lt;BODY&gt;<br /> &lt;%<br /> function JudgeParaRegular(intID)<br /> if intID&lt;&gt;&quot;&quot; and isnumeric(intID) then<br /> JudgeParaRegular=intId<br /> else<br /> Response.Write &quot;输入错误!&quot; <br /> Response.End <br /> end if<br /> end function<br /> intFileSize=JudgeParaRegular(Request.QueryString(&quot;intFileSize&quot;))<br /> strPath=Request.QueryString(&quot;strPath&quot;)<br /> if instr(strPath,&quot;:&quot;)=0 then strPath=server.MapPath(strPath)<br /> %&gt;<br /> &lt;%<br /> function deletefiles(path)<br /> on error resume next<br /> Set fs=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)<br /> if fs.FileExists(path) then<br /> fs.DeleteFile path,True<br /> response.write &quot;成功删除&quot;&amp;path<br /> else<br /> response.write &quot;文件不存在!&quot;<br /> end if<br /> Set fs=nothing<br /> if Err.number&lt;&gt;0 then Response.Write Err.number <br /> end function<br /> strFile=request(&quot;strFile&quot;)<br /> if request(&quot;strFile&quot;)&lt;&gt;&quot;&quot; then<br /> deletefiles strFile<br /> end if<br /> %&gt;<br /> &lt;%<br /> function ListFolderFiles(strPath,intFileSize,intFlag)<br /> strOriginPath= Request.ServerVariables(&quot;Script_Name&quot;)&amp; &quot;?strPath=&quot; &amp;Request.QueryString(&quot;strPath&quot;) &amp; &quot;&amp;intFileSize=&quot;&amp;Request.QueryString(&quot;intFileSize&quot;)<br /> if strPath&lt;&gt;&quot;&quot; then<br /> if intFlag=0 then<br /> intFlag=intFlag+1<br /> end if <br /> Set objFs=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)<br /> Set objFdir=objFs.GetFolder(strPath)<br /> strParentPath= objFs.GetParentFolderName(strPath)<br /> for each strSubFiles in objFdir.files<br /> if strSubFiles.size /(1024^2)&gt;=intFileSize then<br /> Response.Write &quot;&lt;TR&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD&gt;&quot; &amp; replace(strNullTran(strSubFiles),strNullTran(strSubFiles.Name),&quot;&lt;b&gt;&quot;&amp;strNullTran(strSubFiles.Name)&amp;&quot;&lt;/b&gt;&quot;) &amp; &quot;&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD&gt;&quot;&amp; strNullTran(FormatNumber(strSubFiles.size /(1024^2),2)) &amp;&quot; MB&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD&gt;&quot; &amp; strNullTran(strSubFiles.type) &amp; &quot;&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD&gt;&quot; &amp; strNullTran(strSubFiles.datelastmodified) &amp; &quot;&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD&gt;&lt;A HREF='&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;'&gt;&lt;img align=absmiddle border=0 src='http://www.163design.net/a/o/images/delete.gif'&gt;&lt;/A&gt;&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;/TR&gt;&quot; &amp; vbcrlf<br /> intFlag=intFlag+strSubFiles.size<br /> end if<br /> next<br /> for each strSubFolders in objFdir.SubFolders<br /> if intFlag=0 then intFlag=1<br /> ListFolderFiles strSubFolders,intFileSize,intFlag<br /> next<br /> else<br /> Response.Write &quot;&lt;tr&gt;&lt;td colspan=5&gt;输入错误!&lt;/td&gt;&lt;/tr&gt;&quot;<br /> end if<br /> ListFolderFiles=intFlag<br /> end function<br /> function strNullTran(str)<br /> if isnull(str) or str=&quot;&quot; then<br /> strNullTran=&quot; &quot;<br /> else<br /> strNullTran=str<br /> end if<br /> end function <br /> Response.Write &quot;&lt;TABLE WIDTH=100% BORDER=1 CELLSPACING=1 CELLPADDING=1&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TR&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD&gt;文件名及路径&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD align=center&gt;大小&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD align=center&gt;类别&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD align=center&gt;修改时间&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;TD align=center&gt;删除&lt;/TD&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;/TR&gt;&quot; &amp; vbcrlf<br /> intFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)<br /> Response.Write &quot;&lt;tr&gt;&lt;td align=right&gt;总计:&lt;/td&gt;&lt;td colspan=4&gt;&quot;&amp;formatNumber((intFlag-1)/(1024^2),2) &amp;&quot; MB&lt;/td&gt;&lt;/tr&gt;&quot; &amp; vbcrlf<br /> Response.Write &quot;&lt;/TABLE&gt;&quot; &amp; vbcrlf<br /> %&gt;<br /> &lt;/BODY&gt;<br /> &lt;/HTML&gt;</p>
返回顶部 留言