Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why CFileDialog::GetNextPathName doesn't work when the file path is long?

Using CFileDialog class, I select multiple files placed in a directory with a long path. It's OK when I select only one or two files; but when I select three files at the same time it returns only a part of the third file path. (Looks like it's limited to 512 characters possibly) How can I resolve this?

like image 756
Javid Avatar asked Feb 15 '13 21:02

Javid


1 Answers

MFC uses a default buffer of size _MAX_PATH and that's why you are seeing that behavior. Look at dlgfile.cpp for the implementation of CFileDialog::CFileDialog and you will see m_ofn.lpstrFile and m_ofn.nMaxFile being set.

You can specify a larger buffer if you want to. Before calling DoModal you can either access the CFileDialog::m_pOFN member to get a pointer to the OPENFILENAME that the CFileDialog will use and update it directly or call CFileDialog::GetOFN to get a reference to the structure and update that.

Either way you will find this helpful: http://msdn.microsoft.com/en-US/library/ms646839(v=vs.80).aspx

like image 73
Nik Bougalis Avatar answered Oct 15 '22 04:10

Nik Bougalis