The cfiledialog class is used to select a file, but for multiple selections, the default maximum number of selected files is limited, and its maximum string buffer size is only 260. In this case, the data member m_ofn needs to be processed, the following code is used:
DWORD nfilenumbers = 500; // maximum number of files selected by cfiledibers filedlg (true, _ T ("TXT"), _ T ("*. TXT "), ofn_filemustexist | ofn_hidereadonly | ofn_allowmultiselect, text (" file (*. TXT) | *. TXT | all files (*. *) | *. * | "), this); position Pos = 0; cstring strfile; tchar * pbufold = filedlg. m_ofn.lpstrfile; // save the old pointer DWORD dwmaxold = filedlg. m_ofn.nmaxfile; // save the old number of filedlg. m_ofn.lpstrfile = new tchar [nfilenumbers * Max_path]; zeromemory (filedlg. m_ofn.lpstrfile, sizeof (tchar) * nfilenumbers * max_path); filedlg. m_ofn.nmaxfile = nfilenumbers * max_path; // The maximum number, which is interpreted as filedlg by msdn. m_ofn.lpstrfile indicates the maximum number of characters in the buffer. // The default value is 260 If (idok! = Filedlg. domodal () goto exit_onbnclickedcreatebatch; Pos = filedlg. getstartposition (); While (POS) {strfile = filedlg. getnextpathname (POS); createlicfilebyeachhardcode (maplicinfo, strfile);} exit_onbnclickedcreatebatch: Delete [] (filedlg. m_ofn.lpstrfile); // clears the filedlg of the heap memory. m_ofn.lpstrfile = pbufold; // restore the previous pointer because it has not gone deep into the source code analysis of cfiledialog. If you do not know whether this is necessary, restore it first,
// Maybe cfiledialog should be used for analysis.
Filedlg. m_ofn.nmaxfile = dwmaxold; // The maximum number before restoration.