Link to home
Start Free TrialLog in
Avatar of BlakeMcKenna
BlakeMcKennaFlag for United States of America

asked on

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

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!

Thanks,
Blake
Avatar of sirbounty
sirbounty
Flag of United States of America image

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)
Next
Avatar of BlakeMcKenna

ASKER

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.

Thanks,
Actually, there is no listcount property. At least I didn't see one thru intellisense!
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
            Application.DoEvents()
            Debug.Print(FileListBox1.Items(i))

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

        Next
        MsgBox("Done!")
    End Sub

End Class
How do I reference the filename?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial