multi-select for CFileDialog

hi all,
the CFileDialog probably has a limitation of the qountity of files it can choose in one iteration of multi-select. when it exceeds the num of files it can choose, the DoModal returns IDCANCEL, and I have no way of knowing why it failed.
my question is how can I tell after the DoModal() failed that it is due to the num of files that were picked, and not because user simply clicked "Cancel"?
10x, RanBN
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

V_BapatConnect With a Mentor Commented:
Download the sample application from this site:

The buffer size is defined by the member variable m_szBigBuffer in CustomFileDialog.h

Try it out.
RanBNAuthor Commented:
Edited text of question.
Call the ::CommDlgExtendedError function.
If you follow Chensu's comment you will get the error : FNERR_BUFFERTOOSMALL

This is because CFileDialog set the buffer which stores the file names(lpstrFile member of OPENFILENAME struct) to 260 chars.

You can derive a class from CFileDialog and set the buffer size to what you want.

RanBNAuthor Commented:
10x both,
Can you give an example? I tried playing with it, allocating memory, defining the nMaxFile field,  and I managed to pick multy files. but still I have 2 problems:
1. the first is that the "file name" field contains garbage (NULL in the lpszFileName variable in CFileDialog Ctor didn't help)
2. Altough I delete my allocated buffer, I get "Out of memory" message box quite often (my allocation fails).
All Courses

From novice to tech pro — start learning today.