This article illustrates the method of obtaining file size by VB. Share to everyone for your reference. The implementation method is as follows:
<% ' Copyright (c) 2009, reusablecode.blogspot.com; some rights. ' This work is licensed under the Creative Commons attribution.
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 = Array ("B", "KB", "MB", "GB "," TB "," PB "," EB "," ZB "," YB ") factor = log (size) \ 7 Formatfilesize = Round (Size/(1024 ^ factor), 2) & UN Its (factor) End Function%>
I hope this article will help you with your VB programming.