Get size of file using vb.net

  • Thread starter Thread starter XxLicherxX
  • Start date Start date
X

XxLicherxX

Hello everyone,

I need to get the size of a file using vb.net. I have tried using the
Length property from the FileInfo class, but the values its returning
aren't making any sense. For example, I had a 1 KB file and the value
returned was 358. For another 1 KB file, the value 160 was returned.

Thanks
 
XxLicherxX said:
I need to get the size of a file using vb.net. I have tried using the
Length property from the FileInfo class, but the values its returning
aren't making any sense. For example, I had a 1 KB file and the value
returned was 358. For another 1 KB file, the value 160 was returned.

How did you determine that the file's size is 1 KB?
 
Windows explorer with the details view... but if I right click and do
properties 358 bytes. Now I get it. Windows explorer must round up.

Thanks
 
yes, it generally does for the detail views and status messages for a file.
To get the actual size always use the files properties.
 
remember that cluster size on disk has an effect on the "size" explorer
reports too... NTFS clusters are usually 4KB in size... so a 100 byte file
actually takes up 4KB on the disk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top