VB.Net 2005 - FileListBox, DriveListBox, DirectoryListBox Controls Question?

Posted on 2007-04-02
Last Modified: 2012-05-05
I am using the VB6 FileListBox, DriveListBox, and DirectoryListBox controls in my VB.Net 2005 app. I have the filter set on the FileListBox. What I need to do is select all the files in the FileListBox using my app without the users interaction. I then wish to process each selected file in a for loop. I'm just not sure what properties/methods to use for the FileListBox.

Please help!

Question by:BlakeMcKenna
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 67

Expert Comment

ID: 18837015
What are you wanting to do 'with' the files?
You should be able to simply loop through them...

Dim x As Int16
For x = 0 To File1.ListCount - 1
  Console.WriteLine File1.List(x)

Author Comment

ID: 18837081
I just want to open them and process the data. I just wasn't sure how to select them or if I needed to. However, the ListCount property should work.


Author Comment

ID: 18837087
Actually, there is no listcount property. At least I didn't see one thru intellisense!
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18837380
Those controls have been "updated" to be more consistent with .Net syntax so they have an Items() collection now...

Public Class Form1

    Private Sub FormC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FileListBox1.Path = "c:\"
        FileListBox1.Pattern = "*.txt"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i As Integer = 0 To FileListBox1.Items.Count - 1
            FileListBox1.SelectedIndex = i

            System.Threading.Thread.Sleep(250) ' simulated processing

    End Sub

End Class

Author Comment

ID: 18837474
How do I reference the filename?
LVL 86

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 18837483
I showed that in this line:   =)


So use "FileListBox1.Items(i)"...


Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question