rursw1
rursw1

Reputation:

File Attribute is read only when its folder is read only and the file is not

Anyone has any idea?? GetFileAttributes returns 32 (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE). The file is C:\WINDOWS\system32\drivers\etc\hosts.

Thanks a lot!

Upvotes: 0

Views: 2369

Answers (3)

rursw1
rursw1

Reputation:

It returns 33 (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE). The hosts file ISN'T read only, but it is the return value.

Upvotes: 0

Brian R. Bondy
Brian R. Bondy

Reputation: 347566

Which of the following is your situation?

1) GetFileAttributes returns 33 (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE)

or

2) GetFileAttributes returns 32 (FILE_ATTRIBUTE_ARCHIVE)

If the hosts file does not have the read only attribute, and GetFileAttributes does not return INVALID_FILE_ATTRIBUTES then you can trust it's return value. So if the file actually doesn't have the read only attribute, then you have situation #2 above.

Upvotes: 0

Sahas
Sahas

Reputation: 11419

http://msdn.microsoft.com/en-us/library/aa364944(VS.85).aspx

Take a look at this. Response 32 is only FILE_ATTRIBUTE_ARCHIVE. So your code is working fine.

Upvotes: 2

Related Questions