Dear All,
I want to know how can I check whether a file is hidden or not.
e.g. I give file name to code and it should tell whether the file is hidden or not.
I think this can be done by using fso but don't know how.
Please help and guide.
Thanks.
Printable View
Dear All,
I want to know how can I check whether a file is hidden or not.
e.g. I give file name to code and it should tell whether the file is hidden or not.
I think this can be done by using fso but don't know how.
Please help and guide.
Thanks.
Here is the code:VB Code:
' This routine also works with open files ' and raises an error if the file doesn't exist. Function GetAttrDescr(filename As String) As String Dim result As String, attr As Long attr = GetAttr(filename) ' GetAttr also works with directories. If attr And vbDirectory Then result = result & " Directory" If attr And vbReadOnly Then result = result & " ReadOnly" If attr And vbHidden Then result = result & " Hidden" If attr And vbSystem Then result = result & " System" If attr And vbArchive Then result = result & " Archive" ' Discard the first (extra) space. GetAttrDescr = Mid$(result, 2) End Function
Do you need any more help on this thread?
You can use Dir or GetAttr:bear in mind that the GetAttr method will error if the file doesn't existVB Code:
Private Function CheckAttr(ByVal sPath As String, Optional ByVal vbAttr As VbFileAttribute = vbNormal) As Boolean ' Using Dir: CheckAttr = Len(Dir(sPath, vbAttr)) ' or ' using GetAttr CheckAttr = GetAttr(sPath) And vbAttr End Function