File Dialog Issue
-
Hello, I have a problem in my MFC project with a CFileDialog. I use it to open multiple files, just to get the files' size, and my code is something like this: CString str; POSITION pos; CFileDialog ldFile(TRUE,"avi", NULL, OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY, "AVI Files (*.avi)|*.avi|All Files (*.*)|*.*||", this); int ret = ldFile.DoModal(); if(ret == IDOK) { pos = ldFile.GetStartPosition(); while(pos) { str = ldFile.GetNextPathName(pos); if (stat(str , &results) == 0) // The size of the file in bytes is in results.st_size files_size[files_count] = results.st_size; files_count++; } } What I observed is that I can open only a limited number of files (the number is smaller when files are larger): if I try anyway to load more files, no file is loaded and the function returns 2 instead of 1 as usual. Can anyone help me solve this issue? Thanks in advance, Marco.
-
Hello, I have a problem in my MFC project with a CFileDialog. I use it to open multiple files, just to get the files' size, and my code is something like this: CString str; POSITION pos; CFileDialog ldFile(TRUE,"avi", NULL, OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY, "AVI Files (*.avi)|*.avi|All Files (*.*)|*.*||", this); int ret = ldFile.DoModal(); if(ret == IDOK) { pos = ldFile.GetStartPosition(); while(pos) { str = ldFile.GetNextPathName(pos); if (stat(str , &results) == 0) // The size of the file in bytes is in results.st_size files_size[files_count] = results.st_size; files_count++; } } What I observed is that I can open only a limited number of files (the number is smaller when files are larger): if I try anyway to load more files, no file is loaded and the function returns 2 instead of 1 as usual. Can anyone help me solve this issue? Thanks in advance, Marco.
-
It's because the buffer used, CFileDialog::m_ofn.lpstrFile, is too small. Check out MSDN help and you'll get the idea how to solve this. (You'll have to allocate a larger buffer, and you can check exactly how large it needs to be)