Function 4301h Set File Attributes

mov cx, Attributes ;attributes to set

mov dx, seg FileName

mov ds, dx

mov dx, offset FileName ;ds:dx points to filename or directory name

mov ax, 4301h ;Set File Attributes

int 21h

jc error_handler ;carry set means error

Set File Attributes (Function 4301h) sets the attributes for a specified file or directory.

Parameters

Attributes

Specifies the new attributes for the file or directory. This parameter can be a combination of the following values:

Value Meaning

ATTR_NORMAL (0000h) File can be read from or written to.
ATTR_READONLY (0001h) File can read from but not written to.
ATTR_HIDDEN (0002h) File is hidden and does not appear in a directory listing.
ATTR_SYSTEM (0004h) File is a system file.
ATTR_ARCHIVE (0020h) File has been archived.

FileName

Points to a zero-terminated ASCII string that specifies the file or directory to set attributes for. This string must be a valid MS-DOS filename or directory name and cannot contain wildcards.

Return Value

If the function is successful, the carry flag is clear. Otherwise, the carry flag is set and the AX register contains an error value, which may be one of the following values:

Value Name

0001h ERROR_INVALID_FUNCTION
0002h ERROR_FILE_NOT_FOUND
0003h ERROR_PATH_NOT_FOUND
0005h ERROR_ACCESS_DENIED

Comments

Only ATTR_HIDDEN and ATTR_SYSTEM are meaningful for directories.

See Also

Function 4300h Get File Attributes