Question Listing Files in an Array

DominicB

Active member
Joined
May 2, 2008
Messages
30
Programming Experience
Beginner
Hi all

OK, I didn't want to ask this 'cos I know the answer's going to be way too easy, but I've struggled with it for long enough really and I can't get to grips with it.

I found the code below on the internet. It lists all the files at a given location in ListBox1, and it works realy well, except I don't want the files in a listbox, I want them in an array, and I just can't manage it for some reason. I also tried MsgBox'ing dra from within the loop to see if it would report but it won't.

What am I doing wrong?

VB.NET:
' make a reference to a directory
        Dim di As New IO.DirectoryInfo("c:\")
        Dim diar1 As IO.FileInfo() = di.GetFiles()
        Dim dra As IO.FileInfo

        'list the names of all files in the specified directory
        For Each dra In diar1
            ListBox1.Items.Add(dra)
        Next dra

DominicB
 
right, you see the wiggly line underneath the word and at the rightmost end there's a widget (a small rectangle)

Point to it

just like in Word, you should get a menu offering help and corrections.. My guess is simply that it will either offer to import it, or offer to fully qualify it for you:

... = System.IO.Directory.GetFiles....

BUt either way it may give a fast resolution to the problem. Directory DOES exist, you can click View menu.. Object Browser and serach for it.. It will be int here and show you more info about it
 
Hi cjard

Well, what do you know - it actually works!:) Cheers for that.
It does indeed offer to import the System.IO for me - and I can see where it's stuck the line of code, so I've learned something.

Many thanks to all who responded to this thread for your time and assistance.

DominicB
 
Back
Top