# Re: 还是有问题.

Posted by 晓芳 on December 24, 1998 at 21:00:44:

In Reply to: 还是有问题. posted by Windows NT user on December 24, 1998 at 15:43:21:

: : 下面这段程式可以将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
: 但是这段程式码只能找出在根目录下一层的目录,再下一层的目录又怎样找出来呢?
既然知道根目录下的目录名称,假设有一目录叫做jeff,
若要找出下一层的目录,就将上面程式的
MYPATH="C:\"改成MYPATH="C:\JEFF\"
这样就可以了!

Follow Ups:

- Re: 还是有问题. 晓芳 21:36:46 12/24/98 (0)