<p>FSO按文件大小浏览文件目录并进行删除操作的方法</p> <p>下面介绍FSO按文件大小浏览文件目录并进行删除操作的方法:</p> <p>&lt;%@ Language=VBScript %&gt;<br /> &lt;%Server.ScriptTimeout=50000%&gt;</p> <p><br /> <br /> <br /> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"><br /> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><br /> <br /> </p> <p><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</p> <p></p> <p>%&gt;</p> <p>&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;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; replace(strNullTran(strSubFiles),strNullTran(strSubFiles.Name),&quot;<b>&quot;&amp;strNullTran(strSubFiles.Name)&amp;&quot;</b>&quot;) &amp; &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot;&amp; strNullTran(FormatNumber(strSubFiles.size /(1024^2),2)) &amp;&quot; MB&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; strNullTran(strSubFiles.type) &amp; &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; strNullTran(strSubFiles.datelastmodified) &amp; &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;<a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;"><img 127.0.0.1="" 19="" 2007-4="" align="absmiddle" beyondpic="" border="0" br="" files="" http:="" src="&lt;a href=" vbcrlf="" /> Response.Write &quot;&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;输入错误!&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;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;&quot; &amp; vbcrlf<br /> intFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)<br /> Response.Write &quot;&quot; &amp; vbcrlf<br /> Response.Write &quot;</a></p> <table border="1" cellpadding="1" cellspacing="1" width="100%"> <tbody> <tr> <td><a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;">文件名及路径</a></td> <td align="center"><a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;">大小</a></td> <td align="center"><a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;">类别</a></td> <td align="center"><a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;">修改时间</a></td> <td align="center"><a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;">删除</a></td> </tr> <tr> <td align="right"><a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;">总计:</a></td> <td colspan="4"><a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;">&quot;&amp;formatNumber((intFlag-1)/(1024^2),2) &amp;&quot; MB</a></td> </tr> </tbody> </table> <p> <p> <p><a href="&quot;&amp; strOriginPath &amp; &quot;&amp;strFile=&quot;&amp;strNullTran(strSubFiles)&amp;&quot;">&quot; &amp; vbcrlf<br /> %&gt;</a></p> </p> </p>
T:0.015785s,M:163.93 KB
返回顶部 留言