Re: How to select a lot of files
Additional info. If I use this supposed 2048 limit it retrieves the first
filename
correctly but the second file name comes through as '\'. If I go beyound
this limit
it gets the first filename and throws an exception on the second one:
"An invalid argument was encountered."
Here's the code:
CString filename;
// Ignore hardcoded strings...There for illustration only
CFileDialog dlg( TRUE, "ext", NULL,
OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT |
OFN_ALLOWMULTISELECT,
"My Files (*.ext)|All files (*.*)|*.*||", this);
POSITION pos;
//const int c_cbBuffSize = (c_cMaxFiles * (MAX_PATH + 1)) + 1;
const int c_cbBuffSize = 2048;
dlg.GetOFN().lpstrFile = filename.GetBuffer(c_cbBuffSize);
dlg.GetOFN().lpstrFile[0] = '\0';
dlg.GetOFN().nMaxFile = c_cbBuffSize - 1;
if (dlg.DoModal() == IDOK) {
pos = dlg.GetStartPosition();
try{
while(pos){
filename = dlg.GetNextPathName(pos);
}
filename.ReleaseBuffer();
}
catch( CException* e )
{
char message[256];
e->GetErrorMessage(message, 255);
e->Delete();
return;
}
}
Thanks,
Drew
"Drew" <dam@dam.com> wrote in message
news:u5tE23L0IHA.2084@TK2MSFTNGP06.phx.gbl...
I'm using OFN_ALLOWMULTISELECT as a CFileDialog style and I am having the
problem that when I select above a certain number of files my DoModal()
call returns IDCANCEL.
The documentation seems to say that by modifying the lpstrFile and
nMaxFile members of the
OPENFILENAME structure I can increase the number of files selectable. The
sample given
in the docs seems to be wrong. What's the proper way to do this?
Thanks,
Drew