|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
list of files in directories?I am trying to find a way to use "dir" to get a list of ALL the files in a
directory. The problem for me is that this needs to be automated, not knowing how many levels of subdirectories there are each time it is run. Any sample code would be helpful. All I know how to do is something like this: Dir(MainDocsPath, vbDirectory) Of course that only returns a "." and I would have to keep coding embedded dirs, but that's hard to do if one doesn't know how many levels deep they are going. THANKS
Show quote
Hide quote
"Monica" <meisf***@supersky.com> wrote in message Monica,news:u$ike2qTGHA.4436@TK2MSFTNGP10.phx.gbl... > I am trying to find a way to use "dir" to get a list of ALL the files in a > directory. The problem for me is that this needs to be automated, not > knowing how many levels of subdirectories there are each time it is run. > > Any sample code would be helpful. All I know how to do is something like > this: > > Dir(MainDocsPath, vbDirectory) > > Of course that only returns a "." and I would have to keep coding embedded > dirs, but that's hard to do if one doesn't know how many levels deep they > are going. > > THANKS > > Type Dir and press F1, then select Example. It shows you how to get the next file in the directory. HTH, DRBarkley Yes, I am aware of that part. What I was wondering is if there is a way to
loop through all directories and just return the FILE NAMES of every single file in every directory, not knowing in advance how many directories deep that is. I am interested in more than just 1st or 2nd level directories and the files in them. Show quoteHide quote "DRBarkley" <David.NOSPAMBarkley@L-3NOSPAMCom.com> wrote in message news:O%23T0EqrTGHA.424@TK2MSFTNGP12.phx.gbl... > > "Monica" <meisf***@supersky.com> wrote in message > news:u$ike2qTGHA.4436@TK2MSFTNGP10.phx.gbl... > > I am trying to find a way to use "dir" to get a list of ALL the files in a > > directory. The problem for me is that this needs to be automated, not > > knowing how many levels of subdirectories there are each time it is run. > > > > Any sample code would be helpful. All I know how to do is something like > > this: > > > > Dir(MainDocsPath, vbDirectory) > > > > Of course that only returns a "." and I would have to keep coding embedded > > dirs, but that's hard to do if one doesn't know how many levels deep they > > are going. > > > > THANKS > > > > > > Monica, > > Type Dir and press F1, then select Example. > > It shows you how to get the next file in the directory. > > HTH, > > DRBarkley > > "Monica" <meisf***@supersky.com> wrote in message Many ways..... here's onenews:e$fSl4rTGHA.1572@tk2msftngp13.phx.gbl... > Yes, I am aware of that part. What I was wondering is if there is a way > to > loop through all directories and just return the FILE NAMES of every > single > file in every directory, not knowing in advance how many directories deep > that is. I am interested in more than just 1st or 2nd level directories > and > the files in them. DirDrill http://vb.mvps.org/samples/project.asp?id=DirDrill ....and, another... Minimal Code for a Recursive Search for Files http://vbnet.mvps.org/code/fileapi/recursivefiles_minimal.htm See the 'Related' section on that page for links to several variations of this sample. -- Ken Halter - MS-MVP-VB - Please keep all discussions in the groups.. DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Show quote
Hide quote
"Monica" <meisf***@supersky.com> wrote Paste the code below into a new form and view the results in the> I am trying to find a way to use "dir" to get a list of ALL the files in a > directory. The problem for me is that this needs to be automated, not > knowing how many levels of subdirectories there are each time it is run. > > Any sample code would be helpful. All I know how to do is something like > this: > > Dir(MainDocsPath, vbDirectory) > > Of course that only returns a "." and I would have to keep coding embedded > dirs, but that's hard to do if one doesn't know how many levels deep they > are going. > > THANKS Immediate window. Change "D:\Temp\" to whatever folder you are interested in. See if that gets you a little farther along.... LFS Private Sub Form_Load() Dim List As New Collection List.Add "D:\Temp\" Do While List.Count ' Put code here to list files in List(1) folder Debug.Print List(1) FindSubs List List.Remove 1 Loop End Sub Sub FindSubs(List As Collection) Dim file As String Dim path As String path = List(1) file = Dir(path & "*.*", vbDirectory) Do While Len(file) If Left(file, 1) <> "." Then If GetAttr(path & file) And vbDirectory Then List.Add path & file & "\" End If End If file = Dir() Loop End Sub
AND Operator and Currency data type
FTP(not boring) Produktlokalisierung - wie funktioniert's? Convert HTML to text Consume Web Map Service (WMS) with VB6 "Save As" question & file extensions Obtain MCSE certificaiton without exams(Pay after check results)100% passing gaurantee Adding treeview programacticlly Syntax Error - Missing Operator - When Using Date ! Refactoring add-in |
|||||||||||||||||||||||