Solved

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

Posted on 2007-04-02
6
2,437 Views
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!

Thanks,
Blake
0
Comment
Question by:BlakeMcKenna
  • 3
  • 2
6 Comments
 
LVL 67

Expert Comment

by:sirbounty
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)
Next
0
 

Author Comment

by:BlakeMcKenna
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.

Thanks,
0
 

Author Comment

by:BlakeMcKenna
ID: 18837087
Actually, there is no listcount property. At least I didn't see one thru intellisense!
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 85

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
            Application.DoEvents()
            Debug.Print(FileListBox1.Items(i))

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

        Next
        MsgBox("Done!")
    End Sub

End Class
0
 

Author Comment

by:BlakeMcKenna
ID: 18837474
How do I reference the filename?
0
 
LVL 85

Accepted Solution

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

    Debug.Print(FileListBox1.Items(i))

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

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now