Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am browsing an image into picturebox on page. I want to calculate its size (in Kb) on label text on same page
Posted
Updated 4-Aug-15 21:11pm
v2
Comments
Sergey Alexandrovich Kryukov 5-Aug-15 2:55am    
Please don't re-post; by apparent reasons, it is considered as abuse.
—SA

1 solution

That's not really something that we can answer: once the image is loaded into the picture box the only size information available is the X and Y dimensions, as the actaul disk-based file size is not related directly to the image - it's a function of teh image content and the file type that it is saved in.


Many (nearly all) image file formats use compression so the size of the file will be different depending on the format you use: JPG files will be considerably smaller than the equivalent BMP file for example.


If you want to display the file size, you must read it when you load the image from the file and store it for later display. That's simple: the FileInfo class[^] will give you that, via the Length property.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900