Get the size of a file.

  • Thread starter Thread starter Heath P. Dillon
  • Start date Start date
H

Heath P. Dillon

Hi,

I want to do something as simple as get the size of a file on the disk.

I use the openfiledialog control to select the file, but the .length
property give me back the length of the file name, not the size of the file.

Whats the easiest way to get the file size ?

Thanks
 
Heath P. Dillon said:
Hi,

I want to do something as simple as get the size of a file on the disk.

I use the openfiledialog control to select the file, but the .length
property give me back the length of the file name, not the size of the
file.

Whats the easiest way to get the file size ?

Use FileLen() for closed files, LOF() for open files.
 
Heath P. Dillon said:
Hi,

I want to do something as simple as get the size of a file on the disk.

I use the openfiledialog control to select the file, but the .length
property give me back the length of the file name, not the size of the
file.

Whats the easiest way to get the file size ?

Thanks


System.IO.FileInfo.Length. There is example code at
http://msdn.microsoft.com/en-us/library/system.io.fileinfo.length.aspx.

FYI, what you were doing was calling String.Length. Use the filename in the
constructor to the FileInfo object.
 
Back
Top