服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - ASP教程 - 使用FSO按文件大小浏览文件目录并进行删除操作

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

2019-11-01 12:46asp教程网 ASP教程

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

  1. <%@ Language=VBScript %>  
  2. <%Server.ScriptTimeout=50000%>  
  3. <HTML>  
  4. <HEAD>  
  5. <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">  
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
  7. </HEAD>  
  8. <BODY>  
  9. <%  
  10. function JudgeParaRegular(intID)  
  11. if intID<>"" and isnumeric(intID) then  
  12. JudgeParaRegular=intId  
  13. else  
  14. Response.Write "输入错误!"  
  15. Response.End  
  16. end if  
  17. end function  
  18. intFileSize=JudgeParaRegular(Request.QueryString("intFileSize"))  
  19. strPath=Request.QueryString("strPath")  
  20. if instr(strPath,":")=0 then strPath=server.MapPath(strPath)  
  21. %>  
  22. <%  
  23. function deletefiles(path)  
  24. on error resume next  
  25. Set fs=Server.CreateObject("Scripting.FileSystemObject")  
  26. if fs.FileExists(path) then  
  27. fs.DeleteFile path,True  
  28. response.write "成功删除"&path  
  29. else  
  30. response.write "文件不存在!"  
  31. end if  
  32. Set fs=nothing  
  33. if Err.number<>0 then Response.Write Err.number  
  34. end function  
  35. strFile=request("strFile")  
  36. if request("strFile")<>"" then  
  37. deletefiles strFile  
  38. end if  
  39.  
  40. %>  
  41.  
  42. <%  
  43. function ListFolderFiles(strPath,intFileSize,intFlag)  
  44. strOriginPath= Request.ServerVariables("Script_Name")& "?strPath=" &Request.QueryString("strPath") & "&intFileSize="&Request.QueryString("intFileSize")  
  45. if strPath<>"" then  
  46. if intFlag=0 then  
  47. intFlag=intFlag+1  
  48. end if  
  49. Set objFs=Server.CreateObject("Scripting.FileSystemObject")  
  50. Set objFdir=objFs.GetFolder(strPath)  
  51. strParentPath= objFs.GetParentFolderName(strPath)  
  52. for each strSubFiles in objFdir.files  
  53. if strSubFiles.size /(1024^2)>=intFileSize then  
  54. Response.Write "<TR>" & vbcrlf  
  55. Response.Write "<TD>" & replace(strNullTran(strSubFiles),strNullTran(strSubFiles.Name),"<b>"&strNullTran(strSubFiles.Name)&"</b>") & "</TD>" & vbcrlf  
  56. Response.Write "<TD>"& strNullTran(FormatNumber(strSubFiles.size /(1024^2),2)) &" MB</TD>" & vbcrlf  
  57. Response.Write "<TD>" & strNullTran(strSubFiles.type) & "</TD>" & vbcrlf  
  58. Response.Write "<TD>" & strNullTran(strSubFiles.datelastmodified) & "</TD>" & vbcrlf  
  59. Response.Write "<TD><A HREF='"& strOriginPath & "&strFile="&strNullTran(strSubFiles)&"'><img align=absmiddle border=0 src='images/delete.gif'></A></TD>" & vbcrlf  
  60. Response.Write "</TR>" & vbcrlf  
  61. intFlag=intFlag+strSubFiles.size  
  62. end if  
  63. next  
  64. for each strSubFolders in objFdir.SubFolders  
  65. if intFlag=0 then intFlag=1  
  66. ListFolderFiles strSubFolders,intFileSize,intFlag  
  67. next  
  68. else  
  69. Response.Write "<tr><td colspan=5>输入错误!</td></tr>"  
  70. end if  
  71. ListFolderFiles=intFlag  
  72. end function  
  73. function strNullTran(str)  
  74. if isnull(str) or str="" then  
  75. strNullTran=" "  
  76. else  
  77. strNullTran=str  
  78. end if  
  79. end function  
  80. Response.Write "<TABLE WIDTH=100% BORDER=1 CELLSPACING=1 CELLPADDING=1>" & vbcrlf  
  81. Response.Write "<TR>" & vbcrlf  
  82. Response.Write "<TD>文件名及路径</TD>" & vbcrlf  
  83. Response.Write "<TD align=center>大小</TD>" & vbcrlf  
  84. Response.Write "<TD align=center>类别</TD>" & vbcrlf  
  85. Response.Write "<TD align=center>修改时间</TD>" & vbcrlf  
  86. Response.Write "<TD align=center>删除</TD>" & vbcrlf  
  87. Response.Write "</TR>" & vbcrlf  
  88. intFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)  
  89. Response.Write "<tr><td align=right>总计:</td><td colspan=4>"&formatNumber((intFlag-1)/(1024^2),2) &" MB</td></tr>" & vbcrlf  
  90. Response.Write "</TABLE>" & vbcrlf  
  91. %>  
  92. </BODY>  
  93. </HTML>  

延伸 · 阅读

精彩推荐