GetFileAttributes Function

Declare Function GetFileAttributes Lib "kernel32.dll" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long

GetFileAttributes returns the attributes of a file or a directory. Attributes determine such things as read-only status, archive status (most files are), hidden status, etc. If the function fails, it will return 0. If the file or directory cannot be found, it will return -1. Otherwise, the return value will be one or more of the file attribute flags.

lpFileNameThe full name of the file or directory to check the attributes of, including the full path.

Example:

' Check the attributes of c:\windows\sol.exe
attribs = GetFileAttributes("C:\Windows\sol.exe")
If (attribs And FILE_ATTRIBUTES_ARCHIVE) <> 0 Then Debug.Print "Archive"
If (attribs And FILE_ATTRIBUTES_READONLY) <> 0 Then Debug.Print "Read-only"
' and so on....

Related Call: SetFileAttributes
Category: Files
Back to the index.


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/getfileattributes.html