# Re: 还有问题.

Posted by 晓芳 on December 24, 1998 at 09:17:34:

In Reply to: 还有问题. posted by Windows NT user on December 24, 1998 at 07:47:16:

: : : 如何寻找在c:\里*.exe档,并把结果存入一个字串阵列呢?
: : 执行DIR("C:\*.EXE")会传回目录中第一个.EXE的档案,
: : 如果接着再执行DIR()不加参数,则传回第二固.EXE档,
: : 直到传回空字串就表示没有.EXE档了!
: : 这样应该就知道怎么做了吧!

: 这个我知道,但怎样连子目录里的档案也找出来?
下面这段程式可以将C:\的所有子目录全找出来,再配合
上面的DIR()就可以达到你的要求了!
Private Sub Command1_Click()
Dim MYPATH As String, MYNAME As String
MYPATH = "c:\" ' Set the path.
MYNAME = Dir(MYPATH, vbDirectory) ' Retrieve the first entry.
Do While MYNAME <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MYNAME <> "." And MYNAME <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MYPATH & MYNAME) And vbDirectory) = vbDirectory Then
Debug.Print MYNAME ' Display entry only if it
End If ' it represents a directory.
End If
MYNAME = Dir ' Get next entry.
Loop
End Sub

Follow Ups:

- 还是有问题. Windows NT user 15:43:21 12/24/98 (2)
  - Re: 还是有问题. 晓芳 21:00:44 12/24/98 (1)
    - Re: 还是有问题. 晓芳 21:36:46 12/24/98 (0)