SetFileAttributes Function

Declare Function SetFileAttributes Lib "kernel32.dll" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long

SetFileAttributes changes the attributes of a file or a directory. The four attributes you can set are archive, read-only, hidden, and system status. Any of the four can be on or off in any order. The function returns 0 if an error occured, or a non-zero value if successful.

lpFileName
The filename or directory, including the full path, to change the attributes of.
dwFileAttributes
One or more of the file attribute flags. FILE_ATTRIBUTE_COMPRESSED and FILE_ATTRIBUTE_DIRECTORY cannot be set.

Example:

' Hide the file c:\apps\data.dat from the user
x = SetFileAttributes("C:\Apps\data.dat", FILE_ATTRIBUTES_ARCHIVE Or FILE_ATTRIBUTES_HIDDEN)
' Archive-type files are regular files

Related Call: GetFileAttributes
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/setfileattributes.html