VB獲取文件大小的方法
本文實(shí)例講述了VB獲取文件大小的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
<%
' Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved.
'
' 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
%>
希望本文所述對(duì)大家的VB程序設(shè)計(jì)有所幫助。
相關(guān)文章
VB實(shí)現(xiàn)的倒計(jì)時(shí)類(lèi)代碼詳解
這篇文章主要介紹了VB實(shí)現(xiàn)的倒計(jì)時(shí)類(lèi)代碼,非常實(shí)用的功能,需要的朋友可以參考下2014-07-07
VB語(yǔ)言使用ADO連接、操作SQLServer數(shù)據(jù)庫(kù)教程
這篇文章主要介紹了VB語(yǔ)言使用ADO連接、操作SQLServer數(shù)據(jù)庫(kù)教程,本文講解詳細(xì)、代碼中有大量注釋,是非常好的一篇教程,需要的朋友可以參考下2014-08-08
Basic求10000以?xún)?nèi)的完美數(shù)
一個(gè)數(shù)的所有真因數(shù)加起來(lái)正好等于這個(gè)自然數(shù)本身,在數(shù)學(xué)上,具有這種性質(zhì)的自然數(shù)叫做完全數(shù)。關(guān)鍵是求出該自然數(shù)k的所有因子。如果k%i為0,則i為k的因子,用循環(huán)語(yǔ)句求出k 的所有真因子(1<=i<=k/2),把它們求和,看是否等于k來(lái)判斷。2015-05-05
VB使用ADO操作Access數(shù)據(jù)庫(kù)
這篇文章主要介紹了VB使用ADO操作Access數(shù)據(jù)庫(kù)的相關(guān)資料,需要的朋友可以參考下2015-06-06
VB實(shí)現(xiàn)鼠標(biāo)繪圖實(shí)例代碼
這篇文章主要介紹了VB實(shí)現(xiàn)鼠標(biāo)繪圖實(shí)例代碼,很實(shí)用的一個(gè)功能,需要的朋友可以參考下2014-07-07
VB使用shell函數(shù)打開(kāi)外部exe程序的實(shí)現(xiàn)方法
這篇文章主要介紹了VB使用shell函數(shù)打開(kāi)外部exe程序的實(shí)現(xiàn)方法,是非常實(shí)用的一個(gè)功能,需要的朋友可以參考下2014-07-07
VB調(diào)用Word拼寫(xiě)檢查功能實(shí)例
這篇文章主要介紹了VB調(diào)用Word拼寫(xiě)檢查功能,非常實(shí)用的功能,需要的朋友可以參考下2014-07-07
VB的TextBox文本框?qū)崿F(xiàn)垂直居中顯示的方法
這篇文章主要介紹了VB的TextBox文本框?qū)崿F(xiàn)垂直居中顯示的方法,比較實(shí)用的功能,需要的朋友可以參考下2014-07-07

