Hi Everyone,
Currently i'm working on a program that required to display all the images of a folder into the screen. I make use of ImageList & List View to get my job done.
Everything is smooth until the programs hits the "OUT OF MEMORY" Error. I have struggled with this error for couple of days. Anyone Kindly help ? Thanks First..
=======
Code
=======
Dim imlTemp As New ImageList
Dim dirFiles() As String = IO.Directory.GetFiles("D:\ImagesFolder")
Dim _imgList As New ImageList
Dim imgSize As New Size
imgSize.Width = 150
imgSize.Height = 150
ListView2.LargeImageList = _imgList
Dim count As Integer = 0
Dim item As New ListViewItem
For Each dirFile As String In dirFiles
For Each extension As String In allowedExtensions
If extension = IO.Path.GetExtension(dirFile) Then
Dim img As New System.Drawing.Bitmap(dirFile)
_imgList.ImageSize = imgSize
_imgList.Images.Add(img.Clone)
ListView2.Items.Add(dirFile, count)
count += 1
End If
Next
Next
Everything is working fine, if the images in a folder is less than abt 8Mb. Anyone could help ?
Currently i'm working on a program that required to display all the images of a folder into the screen. I make use of ImageList & List View to get my job done.
Everything is smooth until the programs hits the "OUT OF MEMORY" Error. I have struggled with this error for couple of days. Anyone Kindly help ? Thanks First..
=======
Code
=======
Dim imlTemp As New ImageList
Dim dirFiles() As String = IO.Directory.GetFiles("D:\ImagesFolder")
Dim _imgList As New ImageList
Dim imgSize As New Size
imgSize.Width = 150
imgSize.Height = 150
ListView2.LargeImageList = _imgList
Dim count As Integer = 0
Dim item As New ListViewItem
For Each dirFile As String In dirFiles
For Each extension As String In allowedExtensions
If extension = IO.Path.GetExtension(dirFile) Then
Dim img As New System.Drawing.Bitmap(dirFile)
_imgList.ImageSize = imgSize
_imgList.Images.Add(img.Clone)
ListView2.Items.Add(dirFile, count)
count += 1
End If
Next
Next
Everything is working fine, if the images in a folder is less than abt 8Mb. Anyone could help ?