2.1.10.57 SetFileAttributes


Description

set a file's attributes

Syntax

BOOL SetFileAttributes( LPCSTR lpcszFilename, DWORD dwFileAttributes )

Parameters

lpcszFilename
[input]full pathname of the file.
dwFileAttributes
[input]new attributes

Return

nonzero if it succeeds, 0 if it fails.

Examples

EX1

// This example shows how to change file attributes of a file.
// Note that the file c:\myfile.txt must exist for this example to run.
int    SetFileAttributes_ex1()
{
    string        strFile = "c:\\myfile.txt";
    if( !strFile.IsFile() )
    	return 0;
 
    // First get and display the old attributes:
    DWORD    dwAttributes = GetFileAttributes(strFile);
    printf("File attributes are: %#x\n", dwAttributes);
 
    // remove read-only attributes
    if( dwAttributes & FILE_ATTRIBUTE_READONLY )
    {
    	dwAttributes &= ~FILE_ATTRIBUTE_READONLY;
    	SetFileAttributes(strFile, dwAttributes);
    } 
   
    return 1;
}

Remark

It sets file attributes.

See Also

GetFileAttributes, GetFileAttributesEx

Header to Include

origin.h

Reference