Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » FileSel&FileList, Path » FileSelector - maximum number of file in one selection
FileSelector - maximum number of file in one selection [message #38661] Wed, 02 January 2013 01:11 Go to next message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
Hi All,

Issue: Selecting a large number of files (say 2000) using FileSelector Return 0 Files.

I have investigated the issue and concluded that it is due to the following line in the win32.cpp

win32.cpp - Line 110 (approx)
bool FileSelector::Execute(bool open, const char *dlgtitle) {
...
OPENFILENAME ofn;
...
int bufsize = ofn.nMaxFile = (multi ? 32000 : _MAX_PATH);
Buffer<char> buffer(bufsize);
*(ofn.lpstrFile = buffer) = 0;
...
}

essentially limiting the size of the buffer for "nMaxFile" in OPENFILENAME structure.

Question-1: Why hard-coded '32000'? according to MSDN nMaxfile is of DWORD type. my understanding is DWORD are typedef for 32bit Int. but even a signed 32bit Int can hold number as big as 2^31 = 2,147,483,647.

Question-2: I understand that creating that big of a buffer is probably not the best thing to do. but is there any other solution exists from which user can select very larger number of files using the "native" looking FileSelect Dialog?

Question-3: Even with the above limitation, FileSelector dialog actually allow the user to select large number of file. however when user does select large number of files, it fails quietly and not even the filenames in the buffer are returned in the 'filename' vector! Is this a bug or a intended behavior?

I have tried the FileSel U++ dialog instead and seem to work perfectly even with very large number of files. but my priority here is to have the Native Win32 look.

Attached is a test project and a folder with 3049 dummy files to select test.

Thanks & Regards
Navi
  • Attachment: TestCase.7z
    (Size: 4.77KB, Downloaded 234 times)

[Updated on: Wed, 02 January 2013 01:55]

Report message to a moderator

Re: FileSelector - maximum number of file in one selection [message #38689 is a reply to message #38661] Sun, 06 January 2013 20:26 Go to previous message
navi is currently offline  navi
Messages: 107
Registered: February 2012
Location: Sydney, Australia
Experienced Member
Quote:

Question-1: Why hard-coded '32000'? according to MSDN nMaxfile is of DWORD type. my understanding is DWORD are typedef for 32bit Int. but even a signed 32bit Int can hold number as big as 2^31 = 2,147,483,647.


I think I have found my answer to question 1:
computer-programming-forum.com/82-mfc/3079430b194caa71.htm

"The Open File dialog itself is able to retrieve the complete list of
files when selected. However, when processing the list of files, the
length of the data processed is limited to 32K bytes due to a
limitation in the maximum data buffer allowed to be passed to
ExpandEnvironmentStrings. So limit was hit and all the selected files
were not open. There is no limit on number of files selected but the
limit on the ExpandEnvironmentStrings API.


Navi

[Updated on: Sun, 06 January 2013 20:35]

Report message to a moderator

Previous Topic: Display FileName without full path
Next Topic: FEATURE REQUEST: Pastable path for FileSel please
Goto Forum:
  


Current Time: Thu Oct 28 02:06:47 CEST 2021

Total time taken to generate the page: 0.00923 seconds