Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to add all images to an imagelist control from a folder, but I don't know the names and extensions of those images, Not even the count. And I want to show those images one by one on timer's tick using loop (non-stop)
Any ideas? Please help
vb.net
visual studio 2010..

What I have tried:

Now I am using the old-school method , calling image from that folder by it's name and extension, and changing it on timer's tick
Posted
Updated 27-Aug-19 1:25am
Comments
phil.o 27-Aug-19 6:05am    
You can:
- get a list of all files in a specific folder.
- filter them, possibly by extension, to only get image files.
- add them to the ImageList.
Now, which part do you need help with?
Maciej Los 27-Aug-19 7:00am    
My virtual 5!

1 solution

If you don't know the filenames but you do know the folder, you utilize the System.IO.DirectoryInfo to enumerate the files.

Plenty of code samples out there can be found with Google, I grabbed this one from
TheScarms.com : List all files in a folder using VB.NET[^]
VB
Imports System.IO
Dim strFileSize As String = ""
Dim di As New IO.DirectoryInfo("C:\temp")
Dim aryFi As IO.FileInfo() = di.GetFiles("*.txt")
Dim fi As IO.FileInfo

For Each fi In aryFi
    strFileSize = (Math.Round(fi.Length / 1024)).ToString()
    Console.WriteLine("File Name: {0}", fi.Name)
    Console.WriteLine("File Full Name: {0}", fi.FullName)
    Console.WriteLine("File Size (KB): {0}", strFileSize )
    Console.WriteLine("File Extension: {0}", fi.Extension)
    Console.WriteLine("Last Accessed: {0}", fi.LastAccessTime)
    Console.WriteLine("Read Only: {0}", (fi.Attributes.ReadOnly = True).ToString)
Next
 
Share this answer
 
Comments
Maciej Los 27-Aug-19 7:27am    
5ed!
MadMyche 27-Aug-19 9:29am    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900