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. application crash in tree control

application crash in tree control

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelp
5 Posts 4 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.
  • S Offline
    S Offline
    sheetal_06
    wrote on last edited by
    #1

    The following is a code snippet for checking the subdirectories. This code is crashing in the highligted line when sStr is "C:\".If it is "D:\" or "E:" it is working. void CBatchPrintDlg::ChkForSubDir( CString sStr, HTREEITEM hTree ) { struct _finddata_t c_file; long hFile; ::SetCurrentDirectory((LPCTSTR)sStr); if( (hFile = _findfirst( "*.*", &c_file )) != -1L ) { if ( IsDirectory ( c_file.attrib ) ) InsertItemTOTree( (LPCTSTR)c_file.name, hTree ); //m_tree.InsertItem((LPCTSTR)c_file.name, hTree ); while( _findnext( hFile, &c_file ) == 0 ):confused: { if ( IsDirectory ( c_file.attrib ) ) { InsertItemTOTree( (LPCTSTR)c_file.name, hTree ); //m_tree.InsertItem((LPCTSTR)c_file.name, hTree ); //break; } } _findclose( hFile ); } } Please help. Thanks.

    R D H 3 Replies Last reply
    0
    • S sheetal_06

      The following is a code snippet for checking the subdirectories. This code is crashing in the highligted line when sStr is "C:\".If it is "D:\" or "E:" it is working. void CBatchPrintDlg::ChkForSubDir( CString sStr, HTREEITEM hTree ) { struct _finddata_t c_file; long hFile; ::SetCurrentDirectory((LPCTSTR)sStr); if( (hFile = _findfirst( "*.*", &c_file )) != -1L ) { if ( IsDirectory ( c_file.attrib ) ) InsertItemTOTree( (LPCTSTR)c_file.name, hTree ); //m_tree.InsertItem((LPCTSTR)c_file.name, hTree ); while( _findnext( hFile, &c_file ) == 0 ):confused: { if ( IsDirectory ( c_file.attrib ) ) { InsertItemTOTree( (LPCTSTR)c_file.name, hTree ); //m_tree.InsertItem((LPCTSTR)c_file.name, hTree ); //break; } } _findclose( hFile ); } } Please help. Thanks.

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      sheetal_06 wrote:

      "C:\".If it is "D:\" or "E:"

      Do all of these have subdirectories ?

      http://www.readytogiveup.com/[^] - Do something special today. http://www.totalcoaching.ca/[^] - Give me some feedback about this site !

      S 1 Reply Last reply
      0
      • S sheetal_06

        The following is a code snippet for checking the subdirectories. This code is crashing in the highligted line when sStr is "C:\".If it is "D:\" or "E:" it is working. void CBatchPrintDlg::ChkForSubDir( CString sStr, HTREEITEM hTree ) { struct _finddata_t c_file; long hFile; ::SetCurrentDirectory((LPCTSTR)sStr); if( (hFile = _findfirst( "*.*", &c_file )) != -1L ) { if ( IsDirectory ( c_file.attrib ) ) InsertItemTOTree( (LPCTSTR)c_file.name, hTree ); //m_tree.InsertItem((LPCTSTR)c_file.name, hTree ); while( _findnext( hFile, &c_file ) == 0 ):confused: { if ( IsDirectory ( c_file.attrib ) ) { InsertItemTOTree( (LPCTSTR)c_file.name, hTree ); //m_tree.InsertItem((LPCTSTR)c_file.name, hTree ); //break; } } _findclose( hFile ); } } Please help. Thanks.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Since you are using MFC, why not utilize CFileFind? It's much cleaner. What exactly is your code supposed to be doing? There's no need to call SetCurrentDirectory().


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        1 Reply Last reply
        0
        • R Rage

          sheetal_06 wrote:

          "C:\".If it is "D:\" or "E:"

          Do all of these have subdirectories ?

          http://www.readytogiveup.com/[^] - Do something special today. http://www.totalcoaching.ca/[^] - Give me some feedback about this site !

          S Offline
          S Offline
          sheetal_06
          wrote on last edited by
          #4

          ya all have sub directories.

          1 Reply Last reply
          0
          • S sheetal_06

            The following is a code snippet for checking the subdirectories. This code is crashing in the highligted line when sStr is "C:\".If it is "D:\" or "E:" it is working. void CBatchPrintDlg::ChkForSubDir( CString sStr, HTREEITEM hTree ) { struct _finddata_t c_file; long hFile; ::SetCurrentDirectory((LPCTSTR)sStr); if( (hFile = _findfirst( "*.*", &c_file )) != -1L ) { if ( IsDirectory ( c_file.attrib ) ) InsertItemTOTree( (LPCTSTR)c_file.name, hTree ); //m_tree.InsertItem((LPCTSTR)c_file.name, hTree ); while( _findnext( hFile, &c_file ) == 0 ):confused: { if ( IsDirectory ( c_file.attrib ) ) { InsertItemTOTree( (LPCTSTR)c_file.name, hTree ); //m_tree.InsertItem((LPCTSTR)c_file.name, hTree ); //break; } } _findclose( hFile ); } } Please help. Thanks.

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            Are you sure sStr is C:\ when you got error and also why you dont use of value return of SetCurrentDirectory?


            WhiteSky


            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