Microsoft KB Archive/87554

= BUG: CArchiveException for Read-only and Write-only Files =

Article ID: 87554

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 6.1

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Learning Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q87554

<div class="symptoms_section">

SYMPTOMS
The CArchiveExceptions for read-only and write-only archives are not thrown by the Microsoft Foundation Class Library. This condition can be caught by checking for an access denied CFileException.

<div class="cause_section">

CAUSE
This is an oversight of the MFC libraries. The CArchive class does not utilize a try/catch block in its member functions that actually perform the serialization. Thus, a CArchiveException will never be thrown for read-only and write-only archives.

<div class="resolution_section">

RESOLUTION
To test for this condition, look for a CFileException with an m_cause value of CFileException::accessDenied.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a problem in the versions of the Microsoft Foundation Classes listed above. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

<div class="moreinformation_section">

MORE INFORMATION
The CArchiveException class is used to handle exceptions that happen when using the CArchive class. The cause of the CArchiveException can be found by checking the m_cause data member of CArchiveException. Two of the values listed for m_cause are CArchiveException::readOnly and CArchiveException::writeOnly. For more information, refer to the Visual C++ Books Online topics for CArchive and CArchiveException.

Keywords: kbbug kbfileio KB87554

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.