application crash in tree control
-
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.
-
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.
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 !
-
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.
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 callSetCurrentDirectory()
.
"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
-
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 !
ya all have sub directories.
-
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.
Are you sure sStr is C:\ when you got error and also why you dont use of value return of SetCurrentDirectory?
WhiteSky