|
-
May 30th, 2006, 07:41 PM
#1
Thread Starter
Addicted Member
fso+file attribute
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.
-
May 30th, 2006, 07:46 PM
#2
Re: fso+file attribute
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
-
May 30th, 2006, 07:53 PM
#3
Re: fso+file attribute
Do you need any more help on this thread?
-
May 30th, 2006, 08:15 PM
#4
Re: fso+file attribute
You can use Dir or GetAttr:
VB 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
bear in mind that the GetAttr method will error if the file doesn't exist
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|