×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

File size - how?
2

File size - how?

File size - how?

(OP)
Colleagues,

I need to get the size, in bytes, of a file on disk.
The documentation for VB .NET 2012 ain't helping: https://docs.microsoft.com/en-us/dotnet/api/system... has the array of strings which I do not need, and I cannot figure out (syntax!) how to get a single file's size.

AHWBGA!

Regards,

Ilya

RE: File size - how?


CODE

Public Function GetSizeKB(ByVal filename As String) As Double
    ' There are 1024 bytes in a kilobyte
    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 / 1024


---- Andy

There is a great need for a sarcasm font.

RE: File size - how?

(OP)
Exactly what I was looking for!
Thank you, colleague!

Regards,

Ilya

RE: File size - how?

Little Google goes a long way... wavey3


---- Andy

There is a great need for a sarcasm font.

RE: File size - how?

Or perhaps the slightly faster, slightly more lightweight


CODE

    Public Function GetSizeKB(ByVal filename As String) As Double
        ' There are 1024 bytes in a kilobyte
        Return FileLen(filename) / 1024
    End Function 

The choice is yours!

RE: File size - how?

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close