Public Shared Function InitImageListFromDirectory(pDirectory As String) As ImageList
Dim imageList As New ImageList()
For Each f As String In System.IO.Directory.GetFiles(pDirectory)
Try
Dim img As Image = Image.FromFile(f)
imageList.Images.Add(img)
' Out of Memory Exceptions are thrown in Image.FromFile if you pass in a non-image file.
Catch
End Try
Next
Return imageList
End Function
No comments:
Post a Comment