Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image's weight!

Status
Not open for further replies.

McKaulick

Programmer
Oct 24, 2002
35
AR
Hi all, I have a little Windows.Forms program that can browse through the disk to get images and then gives me the width and the height of the image... But I want to have as well the weight of the image, the Ko, the size. How can I have this! There's is properties for width and height but not for weight... Maybe I missed something.

string varHeight, varWidth, varSize;

varHeight = img.Height.ToString()+ " px";
varWidth = img.Width.ToString()+ " px";
varSize = img.????????????? + " Ko";
 
The number of bytes will be the same as the filesize.

BTW, what does "Ko" stand for?

Chip H.
 
I meant Kilobytes... :eek:|

Well, actually I don't know what you wanted to say with you answer! I still don't know how to how I can have the kilobytes of the image!

Have something more specific?

Thx anyway...

Mckaulick
 
You'll need to use the System.IO namespace, then create an instance of a FileInfo class. It has a Length property that will tell you the file's size.
Code:
Using System.IO
 :
 :
 :
FileInfo MyFileInfo = new FileInfo("c:\\somefile.txt");
Console.WriteLine(MyFileInfo.Length.ToString());

Chip H.
 
Thanks, that's exactly what I wanted... Thank you!

McKaulick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top