为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > 获得文件夹的文件名VB

获得文件夹的文件名VB

2017-12-01 3页 doc 15KB 19阅读

用户头像

is_841159

暂无简介

举报
获得文件夹的文件名VB获得文件夹的文件名VB Option Explicit '************************************************************** *********** '**模 块 名:ModSearchFile '**说 明:搜索文件 '**创 建 人:嗷嗷叫的老马 '**日 期:2004年10月27日 '**版 本:V1.0 '************************************************************** ********...
获得文件夹的文件名VB
获得文件夹的文件名VB Option Explicit '************************************************************** *********** '**模 块 名:ModSearchFile '**说 明:搜索文件 '**创 建 人:嗷嗷叫的老马 '**日 期:2004年10月27日 '**版 本:V1.0 '************************************************************** *********** Private FoundFile() As String '存放传回值的字串阵列 Private Ntx As Long Public Function SearchFileInPath(ByVal thePath As String, ByVal theFileName As String, Optional ByVal mStop As Boolean = Fals e) As String() '使用递归方式搜索文件 'thePath - 要搜索的目录 'theFileName - 文件名,支持通配符 'mStop - T=找到一个就返回,F=返回所有找到的文件 '返回值: ' 搜索到的文件 If Right(thePath, 1) <> "\" Then thePath = thePath & "\" Call GetFileLoop(thePath, theFileName, mStop) SearchFileInPath = FoundFile End Function Private Function GetFileLoop(CurrentPath As String, ByVal SearF ile As String, Optional ByVal mStop As Boolean = False) As Stri ng Dim nI As Integer, nDirectory As Integer, I As Long Dim sFileName As String, sDirectoryList() As String On Error Resume Next sFileName = Dir(CurrentPath, vbHidden Or vbDirectory Or vbR eadOnly Or vbSystem) Do While sFileName <> "" If UCase(sFileName) Like UCase(SearFile) Then I = GetAttr(CurrentPath + sFileName) If (I And vbDirectory) = 0 Then If mStop = False Then ReDim Preserve FoundFile(Ntx) FoundFile(Ntx) = CurrentPath + sFileName Ntx = Ntx + 1 Else GetFileLoop = CurrentPath + sFileName Exit Function End If End If End If If sFileName <> "." And sFileName <> ".." Then If GetAttr(CurrentPath & sFileName) _ And vbDirectory Then nDirectory = nDirectory + 1 ReDim Preserve sDirectoryList(nDirectory) sDirectoryList(nDirectory) = CurrentPath & sFil eName End If End If sFileName = Dir Loop For nI = 1 To nDirectory GetFileLoop = GetFileLoop(sDirectoryList(nI) & "\", Se arFile) If GetFileLoop <> "" And mStop = True Then Exit For Next nI End Function
/
本文档为【获得文件夹的文件名VB】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索