|
|
|
Many functions (VB and API) return file/folder/drive size in bytes. To show this size user-friendly, you need to format it in KB, MB or GB. It's easy to do this with a simple math: 1KB = 1024 B, 1MB = 1024 KB etc. and many apps I've seen have a special function to perform this task. But there is a built-in API function: |
Click here to copy the following block | Private Declare Function StrFormatByteSize Lib "shlwapi" Alias "StrFormatByteSizeA" (ByVal dw As Long, ByVal pszBuf As String, ByVal cchBuf As Long) As Long
Private Function GetFormattedSize(ByVal lSize As Long) As String Dim StrOut As String StrOut = Space(64) Call StrFormatByteSize(lSize, StrOut, Len(StrOut) - 1) GetFormattedSize = Trim(StrOut) End Function
Private Sub Form_Load() MsgBox "Calc.exe file length = " & GetFormattedSize(FileLen("c:\windows\calc.exe")) End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|