Name
SetFileAttributes -- set attributes of a file or directory (V3.0)
Synopsis
SetFileAttributes(f$, t)
Function
This function can be used to change one or multiple attributes of a file or directory. This includes information such as the file time, protection flags, and more, depending on the host file system.

The file (or directory) whose attributes you want to change must be passed as parameter f$. The second parameter is a table which contains all attributes you want to modify. The following fields can be set in the table:

Flags:
Use this field to change the protection flags of the file or directory. Set this field to a combination of protection flags or to #FILEATTR_NORMAL to reset all protection flags. See Protection flags for details.

Time:
Use this field to change the time stamp of the file or directory. This field can be used to change the time when the file was last changed. You need to set this field to a string in the format dd-mmm-yyyy hh:mm:ss. E.g.: 08-Nov-2004 14:32:13.

LastAccessTime:
Use this field to modify the time the file or directory was last accessed. The string you specify here must be in the format dd-mmm-yyyy hh:mm:ss. This attribute is not supported on AmigaOS.

CreationTime:
Use this field to modify the creation time of the file or directory. The string you specify here must be in the format dd-mmm-yyyy hh:mm:ss. This attributed is only supported on Win32.

Comment:
Use this field to change the comment of a file. This is only supported by the Amiga versions.

Inputs
f$
name of file or directory whose attributes are to be changed
t
a table containing the attributes to be set
Example
t = {}
t.time = "15-Dec-2006 23:30:12"
t.flags = #FILEATTR_READ_USR | #FILEATTR_WRITE_USR
SetFileAttributes("test.txt", t)
The code above sets the time stamp of file "test.txt" to December 15th, 2006 at 11:30pm and 12 seconds. Additionally it sets the protection flags #FILEATTR_READ_USR and #FILEATTR_WRITE_USR.

Show TOC