程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> VB獲取文件大小的方法

VB獲取文件大小的方法

編輯:VB綜合教程
 

本文實例講述了VB獲取文件大小的方法。分享給大家供大家參考。具體實現方法如下:
<%
'
' This work is licensed under the Creative Commons Attribution License. To view
' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
' 94305, USA.
' Retrieve the file size of a given file.
function getFileSize(someFile)
dim fs
dim file
set fs = Server.CreateObject("Scripting.FileSystemObject")
set file = fs.GetFile(Server.MapPath(someFile))
getFileSize = FormatFileSize(file.size)
set file = nothing
set fs = nothing
end function
' Format a file size in the most practical units.
' Input: size in bytes
function FormatFileSize(size)
dim units
dim factor
units = Array("B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
factor = log(size) \ 7
FormatFileSize = Round(size / (1024 ^ factor), 2) & units(factor)
end function
%>
 

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved