Q: CFile::GetStatus returns incorrect value ?
Shiva Shenoy -- shiva@wallop.com Monday, September 30, 1996 Environment: Win95 VC++ 4.1 static version of CFile::GetStatus on "C:\Temp\12345678.htm" returns non-zero even when the file does not exist on the disk but another file C:\Temp\12345678.html" exists. The Documentation says about the return value - "A value of 0 indicates that the file does not exist." On tracing the MFC source, GetStatus calls FindFirstFile which returns a valid handle and WIN32_FIND_DATA.cFileName has C:\Temp\12345678.html in it !! MFC doesnot check the file name. I do call EnableShellOpen and RegisterShellFileTypes in my InitInstance. Could somebody please explain what should be done to check if a file exists or not ? Shiva Shenoy
Isaac Katzenelson -- isaac_k@goldnet.net.il Wednesday, October 02, 1996 [Mini-digest: 2 responses] Shiva Shenoy wrote: > > Environment: Win95 VC++ 4.1 > > static version of CFile::GetStatus on "C:\Temp\12345678.htm" returns > non-zero even when the file does not exist on the disk but another file > C:\Temp\12345678.html" exists. > > The Documentation says about the return value - "A value of 0 indicates > that the file does not exist." > > On tracing the MFC source, GetStatus calls FindFirstFile which returns > a > valid handle and WIN32_FIND_DATA.cFileName has C:\Temp\12345678.html > in it !! MFC doesnot check the file name. > > I do call EnableShellOpen and RegisterShellFileTypes > in my InitInstance. > Could somebody please explain what should be done to check if a file > exists or not ? > > Shiva Shenoy Hi Shiva I have VC4.2 and it's help says: BOOL GetStatus( CFileStatus& rStatus ) const; static BOOL PASCAL GetStatus( LPCTSTR lpszFileName, CFileStatus& rStatus); Return Value This function always returns TRUE. This is pretty wierd isn't it ? To check for file existance you may open it with CFile::Open and check the return value of this operation. Hope this helps Isaac. ______________________________________________________________________________________ LOOSE WEIGHT NOW, ASK ME HOW ! mailto:isaac_k@goldnet.net.il ______________________________________________________________________________________ -----From: "Erik Funkenbusch"This seems to be a minor problem in the Win95 long file name mechanism. I'm not sure if it's cache related or what, but i've noticed that if you have a file that's 8.3 and rename it so it's 9.3 or 9.4 it will often confuse the two files for the same file name. I think this is a Win95 problem and not an MFC one.
Ash Williams -- ash@digitalworkshop.co.uk Monday, October 07, 1996 I've had similar problems and until I resolve them, I use the _stat struct like so: #include#include BOOL ExistStatus( const CString& rPath ) { BOOL existStatus; struct _stat buffer; existStatus = _stat( rPath, &buffer ) != 0 ? FALSE : TRUE; return existStatus; } Ash
| Вернуться в корень Архива |