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

FileSystemObject and Hidden Files 1

Status
Not open for further replies.

bitwise

Programmer
Mar 15, 2001
269
US
When you loop through a list of files in a directory using the VBScript FileSystemObject:

for each file in oFolder.Files
MsgBox(file.name)
next

That is assuming you have called a GetFolder() on a path - but of course. Anyway, the 'hidden' property is set and you see all hidden files within that directory as well. Does the file object have any file testers that can determine if a file is hidden or not? So that I could do something like:

if(file.IsHidden) then
'do something
end if

Does such a thing exist?

Thanks,
-bitwise
 
Use the Attributes property of the File object:

SET oFSO = WScript.CreateObject("Scripting.FileSystemObject")
SET oFolder = oFSO.GetFolder("C:\MyPath")

For Each oFile In oFolder.Files
If oFile.Attributes And 2 Then
WScript.Echo oFile.Path & " is Hidden"
End If
Next Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top