This is my code to populate a flow-layout-panel with pictureboxes :
For Each fi As FileInfo In New DirectoryInfo(Application.StartupPath + "\data\img\em_sml").GetFiles()
Dim pbx1 As New PictureBox
pbx1.Width = 32
pbx1.Height = 32
pbx1.BackColor = Color.Azure
pbx1.Image = Image.FromFile(fi.FullName)
AddHandler pbx1.Click, AddressOf pbx1_click
FlowLayoutPanel1.Controls.Add(pbx1)
Next
Suddenly i am getting out-of-memory error in the following line :
pbx1.Image = Image.FromFile(fi.FullName)
Why ? and how to fix it ?
Don't know if this is relevant or not, but the problem never occurred when i was using 4 gb ram, yesterday i removed a 2 gb ram stick from my pc, now my pc runs on 2 gb ram. Till yesterday, this error was not there, but now this error appers. Does it have anything to do with RAM ?