Visual Basic 6.0 traverses all files in a folder

Source: Internet
Author: User

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

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.