FIX: Dir Method of File-System Control Ignores vbNormalID: Q184889
|
When using the vbNormal attribute in the Dir method of the File System
control, no files are returned.
This problem occurs whether any specified files are Normal (GetAttr = 0) or
Archive (GetAttr = 32).
Under Visual Basic 5.0, files flagged as Archive (GetAttr returns 32) are
returned if the attribute parameter is set to vbNormal.
The Dir method does not interpret the vbNormal attribute as expected.
To work around this behavior, omit the attribute parameter from the Dir method and use the GetAttr method to check the attribute value (0 for vbNormal or 32 for vbArchive) when the items are read in.
Microsoft has confirmed this to be a problem in the Microsoft products listed
at the beginning of this article.
This problem was corrected in Windows CE Toolkit for Visual Basic 6.0.
Private Sub Form_Load()
Combo1.AddItem "none"
Combo1.AddItem "0 - vbNormal"
Combo1.AddItem "2 - vbHidden"
Combo1.AddItem "4 - vbSystem"
Combo1.AddItem "8 - vbVolume"
Combo1.AddItem "16 - vbDirectory"
Combo1.ListIndex = 0
Combo1_Click
End Sub
Private Sub Combo1_Click()
Dim curDir
Dim curAttr
Dim itemStr
curDir = "\*.*"
curAttr = ""
itemStr = ""
List1.Clear
List1.AddItem "Attributes: " & Combo1.List(Combo1.ListIndex)
Select Case Combo1.ListIndex
Case 0 '"none"
itemStr = FileSystem1.Dir(curDir)
Case 1 '"0 - vbNormal"
itemStr = FileSystem1.Dir(curDir, 0)
Case 2 '"2 - vbHidden"
itemStr = FileSystem1.Dir(curDir, 2)
Case 3 '"4 - vbSystem"
itemStr = FileSystem1.Dir(curDir, 4)
Case 4 '"8 - vbVolume"
itemStr = FileSystem1.Dir(curDir, 8)
Case 5 '"16 - vbDirectory"
itemStr = FileSystem1.Dir(curDir, 16)
End Select
While itemStr <> ""
List1.AddItem itemStr & " - " & _
FileSystem1.GetAttr("\" & itemStr)
itemStr = FileSystem1.Dir
Wend
End Sub
Case 1 '"0 - vbNormal"
itemStr = FileSystem1.Dir(curDir)
While itemStr <> ""
curAttr = FileSystem1.GetAttr("\" & itemStr)
If curAttr = 0 Or curAttr = 32 Then
List1.AddItem itemStr & " - " & curAttr
End If
itemStr = FileSystem1.Dir
Wend
Exit Sub
Books Online for Microsoft Windows CE Toolkit for Visual Basic 5.0
Additional query words: VBCE wce list combo vbce5 vbce6
Keywords : kbToolkit kbVBp kbVBp500 kbVBp600fix kbWinCE kbWinCE100bug kbGrpVB
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: March 3, 1999