Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying system and hidden files in listview control 1

Status
Not open for further replies.

tyhand

Programmer
Jul 3, 2002
186
US
Hi all,

How can I get system and hidden files to display in
a listview control?

I'm using the dir() function with getattr() and am also doing the bitwise comparison but still can't get the
system or hidden folders to display.

BTW, my VB documentation says that I can use the sytem and hidden properties (set to true) with a listview control but those darn things are nowhere to be found in the propety list. They are only listed in the filelistbox control's property list.

Sample code below. Any and all help greatly appreciated. Thanks. *****T Y H A N D

strGetFolder = Dir(Path, vbDirectory)
Do While strGetFolder <> ""
If strGetFolder <> "." And strGetFolder <> ".." Then
If (GetAttr(Path & strGetFolder) And vbDirectory) = vbDirectory Then
Debug.Print strGetFolder
.lvwFolders.SmallIcons = .ImageList1
.lvwFolders.ListItems.Add 1, , strGetFolder, , "ClosedFolder"
ElseIf (GetAttr(Path & strGetFolder) And vbDirectory + vbSystem) = vbDirectory + vbSystem Then
Debug.Print strGetFolder
.lvwFolders.SmallIcons = .ImageList1
.lvwFolders.ListItems.Add 1, , strGetFolder, , "SystemFolder"
ElseIf (GetAttr(Path & strGetFolder) And vbDirectory + vbHidden) = vbDirectory + vbHidden Then
Debug.Print strGetFolder
.lvwFolders.SmallIcons = .ImageList1
.lvwFolders.ListItems.Add 1, , strGetFolder, , "HiddenFolder"
End If
End If
strGetFolder = Dir
Loop
 
See if this change helps. strGetFolder will include Directory, System, read only and hidden.

strGetFolder = Dir(Path, 23)
 
Just a minor change and you will have it:

strGetFolder = Dir(path, vbDirectory + vbSystem + vbHidden)

Otherwise, the Dir function won't return files/directories with those attributes - doh!

Also, you'll want to do the directory only test last in the group, otherwise everything will show as a directory:

If (GetAttr(Path & strGetFolder) And vbDirectory + vbSystem) = vbDirectory + vbSystem Then
...
ElseIf (GetAttr(Path & strGetFolder) And vbDirectory) = vbDirectory Then
...


"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top