79603752

Date: 2025-05-02 16:26:07
Score: 0.5
Natty:
Report link

I know this has been out here a while, but I will try to add to the discussion.

FileInfo does not have a Static method named GetLength

An instantiate object of the class FileInfo does have a property named Length that will return the byte count of the file, this is not the filesize the the OS is going to show you.

To obtain file size (kb, mb, GB) you need to divide the byte Count by a factor of 1024.

FileInfo fi = new("somefileName);

long fiLength = fi.Length; // this is the byte count or size in bytes, a byte is 8 bits

long fileSize = fiLength / 1,024; // this is the filesize or the kilobytes that the file takes up on the physical drive or in memory.

fileSize = fiLength / 1,024,000; to see in MB

long fileSize = fiLength / 1,024,000,000; to see in GB

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Lawrence Thurman