Share via


SetFileAttributes (Compact 2013)

3/26/2014

This function sets the attributes of a file.

Syntax

BOOL SetFileAttributes(
  LPCTSTR lpFileName, 
  DWORD dwFileAttributes
); 

Parameters

  • lpFileName
    [in] Pointer to a string that specifies the name of the file whose attributes are to be set.

    The default string size limit for paths is MAX_PATH characters. This limit is related to how this function parses paths.

  • dwFileAttributes
    [in] File attributes to set for the file. This parameter can be a combination of values. However, all other values override FILE_ATTRIBUTE_NORMAL. The following table shows possible values*.*

    Value

    Description

    FILE_ATTRIBUTE_ARCHIVE

    Indicates that the file or directory is an archive file or directory. Applications use this attribute to mark files for backup or removal.

    FILE_ATTRIBUTE_HIDDEN

    Indicates that the file is hidden. Hidden files and directories are not included in a typical directory listing.

    FILE_ATTRIBUTE_NORMAL

    Indicates that the file has no other attributes set. This attribute is valid only if used alone.

    FILE_ATTRIBUTE_READONLY

    Indicates that the file is read-only. Applications can read the file, but cannot write to it or delete it. In the case of a directory, applications cannot delete it.

    FILE_ATTRIBUTE_SYSTEM

    Indicates that the file or directory is part of, or is used exclusively by, the OS.

    FILE_ATTRIBUTE_TEMPORARY

    Indicates that the file is being used for temporary storage. File systems attempt to keep all data in memory for quicker access, rather than flushing the data back to mass storage. A temporary file should be deleted as soon as it is no longer needed.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

This function does not work on the ROM file system. Inherently, this call is dependent on the file system support provided by a file system driver.

The FILE_ATTRIBUTE_DIRECTORY attribute cannot be set using this function. The CreateFile function and this function cannot be used to create directories. To create a directory, use the CreateDirectory function.

Not all file systems support all attributes.

Requirements

Header

winbase.h

Library

coredll.lib

See Also

Reference

File I/O Functions
CreateDirectory
GetFileAttributes
GetFileAttributesEx