Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File size - how? 2

Status
Not open for further replies.

Code:
Public Function GetSizeKB(ByVal filename As String) As Double
[green]    ' There are 1024 bytes in a kilobyte[/green]
    Return New IO.FileInfo(filename).Length / 1024
End Function

From Calculate The File Size On Disk In KB
To get it in bytes just remove [tt]/ 1024[/tt]


---- Andy

There is a great need for a sarcasm font.
 
Exactly what I was looking for!
Thank you, colleague!

Regards,

Ilya
 
Or perhaps the slightly faster, slightly more lightweight


Code:
[blue]    Public Function GetSizeKB(ByVal filename As String) As Double
        [COLOR=green]' There are 1024 bytes in a kilobyte[/color]
        Return FileLen(filename) / 1024
    End Function[/blue]

The choice is yours!
 
Thank you, Strongm!
Right, I totally forgot about this function, haven't used it (along with the rest of VB) for the last 14 years!
[thanks]

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top