我正在创建一个文件,其中将有一些细节,我不希望任何人能够编辑它。因此,我决定将其保留为只读文件。我尝试了下面的代码,但当我设置状态时,它弹出一个异常。
请告诉我是否有其他的解决方案。
下面是我的代码:
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);发布于 2010-02-22 15:27:52
尝试以下操作之一:
CFile::Close() (在您的示例中为test.Close()),或在具有现有属性(如status.m_attribute |= CFile::readonly.)的只读属性中执行
https://stackoverflow.com/questions/2309301
复制相似问题