By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Load a list of images from a directory

P: 1
Hi, i would like to know the code so when i load a Form it shows me the list of images in a specific folder inside the app folder, but i dont know wich control to use, like imageslist or list view, so when i have in the form the display list of all the images in that folder i can select one and it shows the image in a picture box.

Thank you so much for your help
Mar 14 '14 #1
Share this Question
Share on Google+
2 Replies

P: 2
Hello Luistkd

You can use this to get your application location

Expand|Select|Wrap|Line Numbers
  1. Dim directory As String = My.Application.Info.DirectoryPath
  3. And Use 
  5. Dim di As New IO.DirectoryInfo(directory)
  6. Dim diar1 As IO.FileInfo() = di.GetFiles("*.jpg")
  7. Dim dra As IO.FileInfo
  9. For Each dra In diar1
  10. ListBox1.Items.Add(dra)
  11. Next
  13. To Get The Pictures In A ListBox 
  15. You Can Change This Line If The Pictures Are Not In A .jpg Extension To Any Other Extension
  17. Dim diar1 As IO.FileInfo() = di.GetFiles("*.jpg")
  19. So This Is The Final Code
  21. Dim directory As String = My.Application.Info.DirectoryPath
  22. Dim di As New IO.DirectoryInfo(directory)
  23. Dim diar1 As IO.FileInfo() = di.GetFiles("*.jpg")
  24. Dim dra As IO.FileInfo
  26. For Each dra In diar1
  27. ListBox1.Items.Add(dra)
  28. Next
I Hope This Is What You Were Looking For
Mar 16 '14 #2

Expert Mod 5K+
P: 9,731
Would help us to answer this question if you told us what type of project you are developing: WinForms, WPF, ASP.NET...???

Here is an example of how to accomplish this in a WPF application.

Mar 18 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.