Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CFile::Write() and disk-full condition

CFile::Write() and disk-full condition

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le Thanh Cong
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • L 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

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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(); }

      L 1 Reply Last reply
      0
      • M Mark Salsbery

        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(); }

        L Offline
        L Offline
        Le Thanh Cong
        wrote on last edited by
        #3

        I catched the exception follow: try { file.Write(...); } catch (CFileException*) { AfxMessageBox("xxx"); } But message didn't display

        ----------------- Best Regards, Le Thanh Cong

        M 1 Reply Last reply
        0
        • L 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

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Then the disk isn't full? Step into CFile::Write() and see if the ::WriteFile(...) call succeeds.

          L 1 Reply Last reply
          0
          • M Mark Salsbery

            Then the disk isn't full? Step into CFile::Write() and see if the ::WriteFile(...) call succeeds.

            L Offline
            L Offline
            Le Thanh Cong
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups