Share via


SetFileAttributes

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function sets the attributes of a file. A RAPI version of this function exists called CeSetFileAttributes (RAPI).

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
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

File I/O Functions
CreateDirectory
GetFileAttributes
GetFileAttributesEx