Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3021

CFileDialog mulitple selection limit - is there a workaround ?

$
0
0
In my attempt to capture multiple files using CFileDialog I discovered that there is a limit on the number of characters in the file name buffer. See http://support.microsoft.com/kb/179372

I have used this code to get the file names and it works fine up to the point where the buffer is full. NB: m_vcsPathnames and m_vcsFilenames are std::vector<CString> types.

Code:

        // get  a list of the files to process
        wchar_t szFilters[]= _T("All Files (*.*)|*.*||");

        // Create an Open dialog; the default file name extension "*.*"
        CFileDialog fileDlg(TRUE, _T(""), _T("*.*"),
      OFN_FILEMUSTEXIST| OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilters, this);
       
        m_vcsPathnames.resize(0);
        m_vcsFilenames.resize(0);

        if( fileDlg.DoModal ()==IDOK )
        {
                POSITION pos (fileDlg.GetStartPosition() );
                while( pos )
                {
                        CString csPathname( fileDlg.GetNextPathName( pos ) ); 
                        int n = csPathname.ReverseFind('\\');
                        CString csFilename = csPathname.Right(csPathname.GetLength() - n - 1);  TRACE0("csFilename =: "); OutputDebugString(csFilename); TRACE0("\n");
                        m_vcsPathnames.push_back(csPathname);
                        m_vcsFilenames.push_back(csFilename);
                }

        }

I really need to be able to capture very large numbers of files. Is there any possible work around for this limitation, other than completely writing my own CFileDialogExx class ?

Viewing all articles
Browse latest Browse all 3021

Trending Articles