CFile::Write() and disk-full condition
-
In MSDN, Write() function of CFile class follow: virtual void Write( const void* lpBuf, UINT nCount ); throw( CFileException ); Remarks Writes data from a buffer to the file associated with the CFile object. Write throws an exception in response to several conditions, including the disk-full condition. But in fact, when disk full and application try write to disk then an unhandled exception occur.(CFileException didn't catch) What is cause of this problem?
----------------- Best Regards, Le Thanh Cong
-
In MSDN, Write() function of CFile class follow: virtual void Write( const void* lpBuf, UINT nCount ); throw( CFileException ); Remarks Writes data from a buffer to the file associated with the CFile object. Write throws an exception in response to several conditions, including the disk-full condition. But in fact, when disk full and application try write to disk then an unhandled exception occur.(CFileException didn't catch) What is cause of this problem?
----------------- Best Regards, Le Thanh Cong
Le Thanh Cong wrote:
But in fact, when disk full and application try write to disk then an unhandled exception occur.(CFileException didn't catch)
Looking at the CFile::Write() source code, it only throws CFileException (unless maybe you pass invalid parameters to the function). How are you catching the exception? Like this? try { file.Write(...); } catch (CFileException *e) { e->Delete(); }
-
Le Thanh Cong wrote:
But in fact, when disk full and application try write to disk then an unhandled exception occur.(CFileException didn't catch)
Looking at the CFile::Write() source code, it only throws CFileException (unless maybe you pass invalid parameters to the function). How are you catching the exception? Like this? try { file.Write(...); } catch (CFileException *e) { e->Delete(); }
I catched the exception follow: try { file.Write(...); } catch (CFileException*) { AfxMessageBox("xxx"); } But message didn't display
----------------- Best Regards, Le Thanh Cong
-
I catched the exception follow: try { file.Write(...); } catch (CFileException*) { AfxMessageBox("xxx"); } But message didn't display
----------------- Best Regards, Le Thanh Cong
Then the disk isn't full? Step into CFile::Write() and see if the ::WriteFile(...) call succeeds.
-
Then the disk isn't full? Step into CFile::Write() and see if the ::WriteFile(...) call succeeds.
Thank you, maybe I found cause of this problem. In normal conditions, CFileException will be thrown. But in some special conditions, as multi-thread, communication with devices as USB I/O … then other exception has thrown before that.
----------------- Best Regards, Le Thanh Cong