Determine if file exists in sub folder - HELP!!!

jamesdpmullan

Registered User.
Local time
Today, 17:25
Joined
Oct 21, 2013
Messages
24
Hi,

OK, so I know how to search for a file using the dir function, however, i need to search for a file from a main folder which may have several sub folders.

I am having no luck so far - i understand there is a recursive search facility but im not sure how i can get this to work with what i am trying to achieve.

This is the code i have for the dir function:

Code:
If Len(Dir("\\as-tamworth-50\midlands.qa$\Tamworth\Laminate C of Cs\Circuit Foil\" & CofC & ".")) = 0 Then

    MsgBox "This file does not exist"

    Else

    MsgBox "Yippee"

End If
 
How can i search the contents of [CofC] field in all subfolders within "\\as-tamworth-50\midlands.qa$\Tamworth\Laminate C of Cs\"
 
Laminate C of Cs contains around 10 subfolders.

Any help appreciated.
 
you can't use dir to search multiple folders with subfolders

this will scan a folder

Code:
fname = dir("somepath")
while fname<>""
     fname = dir()
wend
this OUGHT to scan a file system - the logic is OK. But it doesn't work, because dir() does not allow recursion. ie, you cannot continue to the previous level after visiting a subfolder, and continue from the last file checked.

Code:
sub scanfolder(folder as string)
dim fname as string
fname = dir(folder)
while fname<>""
      fname = dir()
       if isfolder(fname) then scanfolder(fname)
wend
 end sub
so you need a solution that doesn't use dir()
 
Hi,

Thanks - i gt the dir function working fine, its just the recursive search im struggling with
 
I haven't got time to upload a recursive search at the moment, but you can't use dir() directly, as I said. There are a few code examples around.
 

Users who are viewing this thread

Back
Top Bottom