Saving image files in GDI Plus
I have two image bitmaps in memory, both of same resolution(height x width x bpp). I would like to save one of them on to a file as JPG. I want to save the one which will take up lesser disk space or have a lesser file size. Can I find out the file size before saving the image?
Ankur JainPosted Aug 19, 2014, 12:21 AM
sorry for that, i guess this time its correct, you can get file size in bytes at the time of uploading by using "FileUpload1.PostedFile.ContentLength" it gives you file size in bytes like this...
Dhaval ShahPosted Aug 18, 2014, 8:01 AM
Ankur JainPosted Aug 18, 2014, 7:52 AM
try like this..
Add namespace:
Using System.IO;
string sMyFileName = "~/photos/test.jpg";
FileInfo finfo = new FileInfo(Server.MapPath(sMyFileName ));
long FileInBytes = finfo.Length;
long FileInKB = finfo.Length / 1024;
long FileInMB = FileInKB /1024;
Response.Write("File Size: " + FileInBytes.ToString() +
" bytes (" + FileInMB.ToString() + " MB)");