Skip to content
⌘ NSIS Forum Archive

Strange work of FindFirst function

3 posts

systracer#

Strange work of FindFirst function

Good day! I find some strange work of FindFirst/FindNext and Locate function.
For example we have 10 dirs on local hard drive:
2017-03-23_02.00.00
2017-03-24_02.00.00
2017-04-05_02.00.03
2017-04-08_02.00.03
2017-04-11_02.00.02
2017-04-12_02.00.03
2017-04-14_02.00.03
2017-04-17_02.00.03
2017-04-18_02.00.02
2017-04-19_02.00.03
And we Find them. All works normal: we get exactly this list in ascending order.
But if this folders locate on network share, connected as letter, we get random order, but each time the same:
2017-04-19_02.00.03
2017-04-05_02.00.03
2017-04-08_02.00.03
2017-04-14_02.00.03
2017-03-23_02.00.00
2017-03-24_02.00.00
2017-04-12_02.00.03
2017-04-18_02.00.02
2017-04-17_02.00.03
2017-04-11_02.00.02
Can this behavior be corrected?
Anders#
Windows does not sort the results. Some filesystems store the directory entries sorted, some store them by creation time. NSIS just returns the entries without any extra sorting.

The order in which the search returns the files, such as alphabetical order, is not guaranteed, and is dependent on the file system. If the data must be sorted, the application must do the ordering after obtaining all the results.
https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

If you are displaying the files in a listbox you can set a style to get the listbox to sort for you...
systracer#
Anders, thanks for answer! I think is universally to sort list in array, if it can't be done more easy.