Change file attributes

This code snippet is originally from the former WinAPI site www.winapi.net

Sometimes you need to change the file attributes, e.g. if you want to delete a write-protected file. This function solves this problem:

#include <windows.h>
 
SetFileAttributes (TEXT("C:\\filename.txt"), FILE_ATTRIBUTE_NORMAL);

The possible attributes can be found in the MSDN.