Reputation: 1626
I am creating a file which will have some details in it, and I don't want anybody to be able to edit it. So, I decided to keep it as a read-only file. I tried the following code but it's popping up an exception when I set the status.
Please tell me if there's an alternative solution.
Here's my code:
CFile test(L"C:\\Desktop\\myText.txt",CFile::modeCreate|CFile::modeWrite);
CFileStatus status;
test.GetStatus(status);
status.m_attribute = CFile::readonly;
test.SetStatus(L"C:\\Desktop\\myText.txt",status);
Upvotes: 1
Views: 1496
Reputation: 78658
Try one of the following:
CFile::Close()
(test.Close()
in your example.)status.m_attribute |= CFile::readonly
.Upvotes: 2