Getting a File size

wtbonnell

Active member
Joined
Oct 6, 2003
Messages
32
Does anyone know how I can get the size of a file (in bytes) that is located on a hard-drive?

It is actually an image file (thumbnail). I tried the following below:

Code:
Bitmap bmp = new Bitmap(imgpath);
int imageSize = bmp.Size;

but that size property represents the dimensions. Any ideas?


Thanks for your help...
 
Something like
C#:
System.IO.FileStream fs; 
fs = System.IO.File.Open(imgpath, /*other parameters required - cant remember them at the moment and I dont have VS on this PC*/ )
int imageSize = fs.Length;
 
Better yet use FileInfo, it doesnt open the file and can provide you with more info.

C#:
System.IO.FileInfo fileInfo = new System.IO.FileInfo(imgpath);
int imageSize = fileInfo.Length;
 
Back
Top