Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image file size checking using c#

i'm trying to load image from local disk, and it's working. But my problem is that i'd like to check if image size is valid or not before loading , and if not - then MessageBox.Show("No image!");

say if image size is zero it should say like "Invalid Image"

and is it possible to check the file extension also

like image 871
user682417 Avatar asked Feb 23 '26 07:02

user682417


2 Answers

Note this is for checking size of file on disk

MSDN FileInfo.Length says that it is "the size of the current file in bytes."

or

You can get the size of image like

Get size of file on disk

or

http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/85bf76ac-a254-41d4-a3d7-e7803c8d9bc3

and putting this thing in if you can show the msg you want

like image 176
Pranay Rana Avatar answered Feb 25 '26 21:02

Pranay Rana


Getting image dimensions without reading the entire file

like image 40
SwDevMan81 Avatar answered Feb 25 '26 20:02

SwDevMan81



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!