Reputation: 139
I've made a windows form application which does some stuff. All works well accept when I want to load files from a remote server which is linux-based.
When loading and just listing the files in a textbox I get different results depending on if I've loaded the files from local storage or from the linux-based server. When done locally the application lists the file in the correct alphabetical order, but not when read from the server. It then just lists the files randomly. (Of course not randomly but you get it, not by file size or file name or anything distinguishable)
Why is this? And what, if anything, can I do about it?
Upvotes: 0
Views: 306
Reputation: 139
In my case, because I was storing the file paths in an array and then displaying the contents of that array, sorting the string array was sufficient.
Array.Sort(filePathArray);
Upvotes: 0
Reputation: 12904
Sort the file before displaying;
var files = from file in Directory.GetFiles(folder)
orderby file descending
select file;
or
var files = Directory.EnumerateFiles(folder)
.OrderByDescending(filename => filename);
for net 4.0 or later.
Upvotes: 1