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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter out system files when displaying files in a listbox

Status
Not open for further replies.

marcin2k

Programmer
Jan 26, 2005
62
CA
I am able to display all files from a folder into a listbox but I want to make it so that system or hidden files do not show up. How can i do this.

Here is my code to display the files:
Private Sub GetDir(sDrive As String)
On Error Resume Next
Dim strRowSource As String
Dim crt
Dim file
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Set crt = FSO.GetFolder(sDrive)
'Files
For Each file In crt.Files
strRowSource = strRowSource & file.Name & ";"
Next
Me!lstFiles.RowSource = strRowSource
End Sub

Thanks,
Marcin
 
For Each file In crt.Files
If Not ((file.Attributes And 2) Or (file.Attributes And 4)) Then
strRowSource = strRowSource & file.Name & ";"
End If
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, I made a slight change I noticed that if I checked if an files attribute = 6 Then i did not display it and it worked cause those ended up being the hidden files
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top