Out of Memory error for Iimage
-
I want to display an image in my custom control.For that i used Image.FromFile(pathofimage)...But this statement gave an out of memory error. This happened when i changed an xml file to format 'bmp' and loaded that image.When i saw the file it had a red crossed symbol. How can i check whether an image file is a valid image file or not?..Please help....
-
I want to display an image in my custom control.For that i used Image.FromFile(pathofimage)...But this statement gave an out of memory error. This happened when i changed an xml file to format 'bmp' and loaded that image.When i saw the file it had a red crossed symbol. How can i check whether an image file is a valid image file or not?..Please help....
Hi, The function "Image.FromFile" can through 2 types of Exceptions. 1)OutOfMemoryException 2)FileNotFoundException The first exception "OutOfMemoryException" will be thrown when the file does not have a valid image format. Hence, you put the above line in a try-catch block. There is problem with file format, when you get an exception type as OutOfMemoryException. Manoj
-
I want to display an image in my custom control.For that i used Image.FromFile(pathofimage)...But this statement gave an out of memory error. This happened when i changed an xml file to format 'bmp' and loaded that image.When i saw the file it had a red crossed symbol. How can i check whether an image file is a valid image file or not?..Please help....
snoby wrote:
when i changed an xml file to format 'bmp'
Why did you change the format of file ?
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
I want to display an image in my custom control.For that i used Image.FromFile(pathofimage)...But this statement gave an out of memory error. This happened when i changed an xml file to format 'bmp' and loaded that image.When i saw the file it had a red crossed symbol. How can i check whether an image file is a valid image file or not?..Please help....
Explain how you "changed an XML file to format BMP"??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Explain how you "changed an XML file to format BMP"??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007While testing with my custom control...testers tried to rename an Xml file to Bmp file.In that extreme case , my custom control should not fail. So while fetching such a file my control failed.I can handle it in try -catch block.This i have already done.But is there any coding to restrict such exceptions from occuring ?
-
While testing with my custom control...testers tried to rename an Xml file to Bmp file.In that extreme case , my custom control should not fail. So while fetching such a file my control failed.I can handle it in try -catch block.This i have already done.But is there any coding to restrict such exceptions from occuring ?
snoby wrote:
testers tried to rename an Xml file to Bmp file.
Of course that's not going to work...
snoby wrote:
In that extreme case , my custom control should not fail. So while fetching such a file my control failed.I can handle it in try -catch block.
That's exactly what you have to do.
snoby wrote:
But is there any coding to restrict such exceptions from occuring ?
You can't predict the future. You have no choice but to handle that exception. Even if the file is intentioned to be a valid image, files CAN be corrupted, no matter what you do. You simply don't have a choice here. You MUST handle the exception.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007