VB 版 (精华区)

发信人: zxfsnow (别怕我伤心), 信区: VB
标  题: 如何用Dir()函数来列出C:\下所有*.TMP文件 
发信站: 哈工大紫丁香 (2000年05月30日19:53:22 星期二), 转信


     如何用Dir()函数来列出C:\下所有*.TMP文件,并且用文本框输出?

Const Filespec$ = "*.tmp"
Const vbBackslash = "\"
Const vbAllFiles = "*.*"
Const vbKeyDot = 46

Private Sub SearchDirs(curpath$)
    Dim dirs%, dirbuf$(), i%
    DoEvents
    hItem$ = Dir(curpath$, vbDirectory)

    Do While hItem$ <> ""
             If (GetAttr(curpath$ & hItem$) And vbDirectory) = vbDirectory
Then
Then
                 If hItem$ <> "." And hItem <> ".." Then
                   If (dirs% Mod 10) = 0 Then ReDim Preserve dirbuf$(dirs% +
10)
                     dirs% = dirs% + 1
                     dirbuf$(dirs%) = curpath$ & hItem$
              End If
            End If
            hItem$ = Dir
        Loop

        Call SearchFileSpec(curpath$)

    For i% = 1 To dirs%: SearchDirs dirbuf$(i%) & vbBackslash: Next i%

End Sub
Private Sub SearchFileSpec(curpath$)
    hFile$ = Dir(curpath$ & Filespec$)
    While Trim$(hFile$) <> ""
        Text1 = Text1 & curpath$ & hFile$ & vbCrLf
        hFile$ = Dir
    Wend
End Sub


Private Sub Form_Load()
Text1 = ""
curpath$ = "C:\"
SearchDirs (curpath$)
End Sub
--
       巧者劳而智者忧,无能者无所求,饱食而遨游,泛若不系之舟。

※ 来源:.虎踞龙盘东南站 sbbs.seu.edu.cn.[FROM: 202.119.29.43] 


--

 以科计为本,以产业报国!
  超越自我,飞跃无限!
  

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.235.249]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.187毫秒