Spath is the path of the searched folder, and list is the list of returned files
Public Function getallfiles (byval Spath as string, list as collection) Dim item as string Dim opaths as new collection Item = Dir (Spath, vbdirectory) While Len (item)> 0 If item <> "." And item <> "..." then If (getattr (fullpathname (Spath) & item) and vbdirectory) = vbdirectory then China Network Management Forum bbs.bitscn.com Opaths. Add item Else If ismodelfile (item) then list. Add Spath & item End if End if Item = dir Wend Dim P For each P in opaths Call getallfiles (combin (Spath, P), list) Next End Function |
Check whether a folder exists
Public Function fullpathname (byval strpath as string) as string Fullpathname = IIF (VBA. Right (strpath, 1) = "/", strpath, strpath &"/") End Function |
Path composed of Multiple folder names
Public Function combin (paramarray Arg () as string Dim X Dim result as string For each X in Arg () Result = Result & fullpathname (X) Next Combin = Result End Function |
-------------------------------------
URL:Http://www.bitscn.com/dotnet/vb/200807/147175.html