FIX: CFile::SetStatus Throws Exception When Setting TimeLast reviewed: September 16, 1997Article ID: Q104638 |
The information in this article applies to:
SYMPTOMSAn attempt to set the status of a file using the function CFile::SetStatus results in a CFileException. If you do not have an exception handler defined, the result will depend on what the target type for the application is:
CAUSEThis behavior occurs whenever the CFileStatus member m_mtime is nonzero. There is a coding problem that incorrectly throws an exception when updating the file time. The following console application duplicates this error:
/* Build as a console application using ** Microsoft Foundation Classes ** Be sure that TEMP.DAT file exists in the same directory. */ #include <afx.h> CFileStatus fs; void main(void) { CFile::GetStatus("TEMP.DAT",fs); CFile::SetStatus("TEMP.DAT",fs); } RESOLUTIONTo work around this problem, update the Microsoft Foundation Class (MFC) library files by making a modification to the MFC source file FILEST.CPP. Remove the semicolon from the end of the "if" statement in line 134: Change the following:
if (!SystemTimeToFileTime((LPSYSTEMTIME)&sysTime, pFileTime));to the following:
if (!SystemTimeToFileTime((LPSYSTEMTIME)&sysTime, pFileTime))You must then rebuild the MFC libraries. For more information on building these library files, refer to:
Run the NMAKE command from the \MSVCNT\MFC\SRC directory. The debug version:
NMAKE MODEL=N TARGET=W DEBUG=1 CODEVIEW=2The release version:
NMAKE MODEL=N TARGET=W DEBUG=0 STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Microsoft Visual C++ 32-bit Edition, version 2.0. Keywords : MfcFileIO Technology : kbmfc Version : 1.0 Platform : NT WINDOWS Issue type : kbbug Solution Type : kbfix |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |