Link to home
Start Free TrialLog in
Avatar of franknasr
franknasr

asked on

How do I get an array of file names from a directory

I have a directory on a server that contains over 40000 files and I need an array to contain the names of all of these files so that I can then do something with them. I was wondering if there was a nice VB tool that could do this for me.

My original thought was to use a file list box and then sequentially grab the names of each file and write them to the array but I discovered that file list boxes cannot handle this many files so I am at a loss.

Thank you for any help you can offer me.


Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

sub ListFiles(sPath as string)
dim arr() as string,ff as string
dim l as long

ff=dir$(sPath & "\*.*", vbarchive)
do while ff<>""
    redim preserve arr(l)
    arr(l)= sPath & "\" & ff
    l=l+1
ff=dir$()
loop
ASKER CERTIFIED SOLUTION
Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland 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
Avatar of franknasr
franknasr

ASKER

This was perfect thank you very much.