asp統計檔案空間大小代碼

來源:互聯網
上載者:User

Dim Fso,FsoFile,FileType,FileSize,FileTime,Path
 Dim Dir
 Action=Trim(Request("Action"))
 Set Fso=Server.CreateObject("Scripting.FileSystemObject")
 IsErr
 If Action = "Del" then
  Call DelAll
 Else
  Dir=Trim(Request.QueryString("Dir"))
  Path = Server.MapPath(UploadFolder) & Dir
  Set FsoFile = Fso.GetFolder(Server.MapPath(UploadFolder))
   FsoFileSize = FsoFile.size '空間大小統計
  Set FsoFile = nothing
  Set FsoFile = Fso.GetFolder(Path)

 Response.Write("<table class='table' cellSpacing='1' cellPadding='3' width='98%' align='center' border='0'>") &vbCrlf
 Response.Write("  <tr>") &vbCrlf
 Response.Write("    <td width='80%' class='hback'> 圖片主目錄:.."&UploadFileDir&"&nbsp;&nbsp;空間佔用:")
 Response.Write GetFileSize(FsoFileSize)
 Response.Write("&nbsp;&nbsp;<br />目前的目錄:<a href='Admin_UpFiles.asp' title='返回主目錄'><font color='#FF0000'>..</font></a><font color='#0000FF'>"&Dir&"</font>&nbsp;&nbsp;佔用空間:")
 Response.Write GetFileSize(FsoFile.size)
 Response.Write("&nbsp;&nbsp;其中包括<font color='#FF0000'>"&FsoFile.SubFolders.count&"</font>個檔案夾;&nbsp;&nbsp;<font color='red'><b>"&FsoFile.Files.count&"</b></font>個檔案</td>") &vbCrlf
 Response.Write("  </tr>") &vbCrlf
 Response.Write("</table>") &vbCrlf
 Response.Write("<form name='form' method='post' action='?Action=Del' style='margin:0'>") &vbCrlf
 Response.Write("<table class='table' cellSpacing='1' cellPadding='3' width='98%' align='center' border='0'>") &vbCrlf
 Response.Write("  <tr class='xingmu' height='22'>") &vbCrlf
 Response.Write("    <th width='10%' height='22' align='center' class='xingmu'>選中</th>") &vbCrlf
 Response.Write("    <th width='30%' align='center' class='xingmu'>檔案/檔案夾名</th>") &vbCrlf
 Response.Write("    <th width='10%' align='center' class='xingmu'>類型</th>") &vbCrlf
 Response.Write("    <th width='15%' align='center' class='xingmu'>檔案大小</th>") &vbCrlf
 Response.Write("    <th align='center' class='xingmu'>最後修改時間</th>") &vbCrlf
 Response.Write("  </tr>") &vbCrlf

     For Each DirFolder in FsoFile.SubFolders
  FolderName=DirFolder.name
  FolderSize=GetFileSize(DirFolder.size)
  FolderTime=DirFolder.DateLastModified

 Response.Write("  <tr onMouseOver='overColor(this)' onMouseOut='outColor(this)'> ") &vbCrlf
 Response.Write("    <td align='center' class='hback'> <input type='checkbox' name='FolderId' value='"&FolderName&"' onClick=""checkItem(this, 'chkAll')""></td>") &vbCrlf
 Response.Write("    <td align='left' class='hback'>&nbsp;<a href=?action=Open&Dir="&Dir&""&FolderName&">"&FolderName&"</a></td>") &vbCrlf
 Response.Write("    <td align='center' class='hback'><img src='"&ImageFolder&"/ClosedFolder.gif' width='16' height='16' alt='檔案夾'></td>") &vbCrlf
 Response.Write("    <td align='center' class='hback'>"&FolderSize&"</td>") &vbCrlf
 Response.Write("    <td align='left' class='hback'>"&FolderTime&"</td>") &vbCrlf
 Response.Write("  </tr>") &vbCrlf

     Next
   For Each DirFiles in FsoFile.Files
  FileName=DirFiles.name
  FileType=GetFileIcon(FileName)
  FileSize=GetFileSize(DirFiles.size)
  FileTime=DirFiles.DateLastModified

 Response.Write("  <tr onMouseOver='overColor(this)' onMouseOut='outColor(this)'>") &vbCrlf
 Response.Write("    <td align='center' class='hback'> <input type='checkbox' name='FileId' value='"&FileName&"' onClick=""checkItem(this, 'chkAll')""></td>") &vbCrlf
 Response.Write("    <td align='left' class='hback'>&nbsp;<a href='"&UploadFolder&Dir&"/"&FileName&"' target='_blank'>"&FileName&"</a></td>") &vbCrlf
 Response.Write("    <td class='hback' align='center'><Img src='"&ImageFolder&"/"&FileType&"' alt='檔案' width='16' height='16'></td>") &vbCrlf
 Response.Write("    <td align='center' class='hback'>"&FileSize&"</td>") &vbCrlf
 Response.Write("    <td align='left' class='hback'>"&FileTime&"</td>") &vbCrlf
 Response.Write("  </tr>") &vbCrlf

     Next
Response.Write("</table>") &vbCrlf
 Response.Write("<table width='98%' border='0' cellspacing='0' cellpadding='0' align='center'>") &vbCrlf
 Response.Write("  <tr>") &vbCrlf
 Response.Write("    <td width='10%' align='center'><input type='checkbox' name='CheckAll' value='checkbox' onClick=""checkAll(this, 'FileId')""></td>") &vbCrlf
 Response.Write(" <td colspan='4' height='30'>&nbsp;<input name='Del' type='submit' class='Button' id='Del' style='cursor:hand' value=' 刪 除 ' onClick=""{if(confirm('確定刪除選定檔案或者檔案夾嗎!?')){this.document.form.submit();return true;}return false;}"">&nbsp;&nbsp;<input type='hidden' name='ThisDir' value='"&Dir&"'>&nbsp;&nbsp;<input name='aa' type='button' class='Button' id='aa' value='返回圖片目錄' onClick=""javascript:window.location.href='Admin_UpFiles.asp';""></td>") &vbCrlf
 Response.Write("  </tr>") &vbCrlf
 Response.Write("</table>") &vbCrlf
 Response.Write("</form>") &vbCrlf

    End If
 Set FsoFile = nothing
 Set Fso = nothing

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.