Solved

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

Posted on 2007-04-02
6
2,447 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

789 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