PublicFunction funFindDirectory(ByVal strDir As String,Optional vMode As Long =vbDirectory) As Integer Dim vfilenames As String Dim vLoop As Integer Dim vfileAttr As fileATTRIB varfileCount = 0 varDirCount = 0 On Error GoTo lopErr If strDir = "" Then strDir = varCurrentPath End If If Right(Trim(strDir),1) <>"\" Then strDir = Trim(strDir) &"\" End If strDir = UCase(strDir) vfilenames = Dir(strDir,vMode) ReDim Preserve vfiles(11) ReDim Preserve vDirectorIEs(11) Err.Clear do while vfilenames <>"" varCurrentPath = strDir If vfilenames <>"." And vfilenames<>".." Then If (GetAttr(strDir&vfilenames) And vbDirectory) = vbDirectory Then If varDirCount Mod10 = 0 Then ReDimPreserve vDirectorIEs(varDirCount + 10) DoEvents End If funGetfileAttribstrDir &vfilenames,vDirectorIEs(varDirCount) varDirCount =varDirCount + 1 Else If varfileCountMod 10 = 0 Then ReDimPreserve vfiles(varfileCount + 10) DoEvents End If funGetfileAttribstrDir &vfilenames,vfiles(varfileCount) varfileCount =varfileCount + 1 End If End If lopErr: vfilenames = Dir(,vbAlias) Loop funQuickSortfile vDirectorIEs(),varDirCount - 1 funQuickSortfile vfiles(),varfileCount - 1 Exit Function 'vErrorMessage = "file Not Found." End Function
总结以上是内存溢出为你收集整理的VB查找指定路径中的文件和目录列表全部内容,希望文章能够帮你解决VB查找指定路径中的文件和目录列表所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)