PRB: "Access to an Unnamed File Was Denied" ErrorLast reviewed: March 4, 1998Article ID: Q181880 |
The information in this article applies to:
SYMPTOMSYou get the following error when calling CFile::Read():
Access to an unnamed file was denied.If run under the Microsoft Visual C++ debugger, you will see the following error:
CFile exception: accessDenied, File Unknown, OS error information = 5 CAUSEYou are actually opening the file without read access. The following intuitively correct code causes the error:
CFile cf; int data; cf.Open("myfile.dat", CFile::modeRead | CFile::modeWrite); cf.Write(&data, sizeof(int)); cf.Read(&data, sizeof(int)); RESOLUTIONSpecify CFile::modeReadWrite instead of the logical OR of CFile::modeRead and CFile::modeWrite.
STATUSThis behavior is by design.
REFERENCESFor more information about CFile, or other MFC classes, consult the Microsoft Visual C++ online help. (c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Joe Crump, Microsoft Corporation Keywords : CodeGen kberrmsg Version : WINNT:4.0,5.0 Platform : winnt Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |