Help! Image.FromFile() causes out of memory exception
-
:(Help! I'm trying to load an icon file into a picturebox using the following code: PictureBox1.Image = Image.FromFile("cow.ico") When executed an "Out of Memory Exception" is thrown every single time. My development machine has 1GB of RAM, and when this happens I have well over 1/2GB of physical memeory available, never mind the page file. The rest of the program isn't very big. There is an array of about 3000 elements in there, but the exception is thrown before that array is initialized or filled. Could this be a problem with my icon file? I use it in several other places with no problems... It does have every possible icon size/colour depth but is only 49K on the drive. What is also curious is that this line works fine (it follows the above) when I comment the picturebox line out: Me.Icon = new Icon("Cow.ico") -Allan
-
:(Help! I'm trying to load an icon file into a picturebox using the following code: PictureBox1.Image = Image.FromFile("cow.ico") When executed an "Out of Memory Exception" is thrown every single time. My development machine has 1GB of RAM, and when this happens I have well over 1/2GB of physical memeory available, never mind the page file. The rest of the program isn't very big. There is an array of about 3000 elements in there, but the exception is thrown before that array is initialized or filled. Could this be a problem with my icon file? I use it in several other places with no problems... It does have every possible icon size/colour depth but is only 49K on the drive. What is also curious is that this line works fine (it follows the above) when I comment the picturebox line out: Me.Icon = new Icon("Cow.ico") -Allan
i just tried it and it worked fine : PictureBox1.Image = Image.FromFile("C:\7.ico") you must have the exact path of the image in there or it will error. switch(twinsOnWay) { case ("twins on the way"): MessageBox.Show("for mr and mrs dynamic","twins on the way"); break;