I'm using SetFileAttributes API to reset FILE_ATTRIBUTE_ARCHIVE
attribute on files. My app that I need it for acts as a backup software. Here's how I do it:
DWORD dwAtt = ::GetFileAttributes(strSrcFilePath);
if(dwAtt != INVALID_FILE_ATTRIBUTES)
{
if(!::SetFileAttributes(strSrcFilePath, dwAtt & ~FILE_ATTRIBUTE_ARCHIVE))
{
//Error
int error = ::GetLastError();
}
}
The user account that my process runs under belongs to the Backup Operators
group:
which according to this document should give my process access to modify files regardless of their permissions.
But when I run the code above, SetFileAttributes
fails with ERROR_ACCESS_DENIED
.
Am I missing something?
Do I need to give my process write-access to the file just to reset its FILE_ATTRIBUTE_ARCHIVE
attribute?