-
April 30th, 2013, 11:26 AM
#1
CFileDialog mulitple selection limit - is there a workaround ?
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 ?
mpliam
-
April 30th, 2013, 11:45 AM
#2
Re: CFileDialog mulitple selection limit - is there a workaround ?
Originally Posted by Mike Pliam
The article states that the issue has been fixed since Windows NT SP 2.
Regards,
Paul McKenzie
-
April 30th, 2013, 09:22 PM
#3
Re: CFileDialog mulitple selection limit - is there a workaround ?
Dang, I'm still running NT4 SP1.
-
May 1st, 2013, 06:17 AM
#4
Re: CFileDialog mulitple selection limit - is there a workaround ?
Where do you set: fileDlg.GetOFN().lpstrFile and fileDlg.GetOFN().nMaxFile ?
-
May 4th, 2013, 02:13 PM
#5
Re: CFileDialog mulitple selection limit - is there a workaround ?
Originally Posted by Mike Pliam
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 ?
CFileDialog is just a thin wrapper over GetOpenFileName. What's the problem to write a function that suits your needs? You do this every single day, don't you?
Last edited by Igor Vartanov; May 4th, 2013 at 02:17 PM.
Best regards,
Igor
-
May 4th, 2013, 02:48 PM
#6
Re: CFileDialog mulitple selection limit - is there a workaround ?
Why use GetOpenFileName instead of CFileDialog ? It had the same restriction that
CFileDialog had. BUt as has been mentioned, that restriction no longer exists. Example:
Code:
CFileDialog fileDlg(TRUE, _T(""), _T("*.*"),
OFN_FILEMUSTEXIST| OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilters, this);
const int minimum_number_of_files = 1000;
const int buffer_size = minimum_number_of_files * (MAX_PATH + 1) + 1;
vector<TCHAR> buffer(buffer_size);
fileDlg.GetOFN().lpstrFile = &buffer[0];
fileDlg.GetOFN().nMaxFile = buffer_size;
// etc
-
May 8th, 2013, 01:54 AM
#7
Re: CFileDialog mulitple selection limit - is there a workaround ?
See also the Remarks section in CFileDialog class documentation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|