473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Searching for files - what sets the return order?

string[] allFiles = Directory.GetFiles(folderPath, filters,
SearchOption.AllDirectories);

I noticed that the order that the files are returned in varies from PC
to PC - some return in alphabetical order; some appear to return in
date modified or something else. In my testing, it seemed that files
within a give subdirectory are returned in alphabetical order, but its
the order that the subfolders themselves are processed in which varies
a lot.

Any thoughts?

Jan 2 '06 #1
3 912
Any thoughts?


Don't write code that depends on the order. If you need them in a
specific order you should sort the list youself.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 2 '06 #2

Mattias Sjögren wrote:
Any thoughts?


Don't write code that depends on the order. If you need them in a
specific order you should sort the list youself.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Yes - I have realised this, and will ensure that any code written will
sort the returned files. However, for an existing problem, I am
looking to give people an interim fix. If we can understand what sets
the return order, then perhaps this will help.

Jan 2 '06 #3
The return order is undefined and depends on the internal implementation of
the filesystem.
You should never rely on the order.

<Sp**************@gmail.com> schrieb im Newsbeitrag
news:11*********************@g43g2000cwa.googlegro ups.com...

Mattias Sjögren wrote:
Any thoughts?


Don't write code that depends on the order. If you need them in a
specific order you should sort the list youself.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Yes - I have realised this, and will ensure that any code written will
sort the returned files. However, for an existing problem, I am
looking to give people an interim fix. If we can understand what sets
the return order, then perhaps this will help.
Jan 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dave Benjamin | last post by:
Hola, I made a backport of sets.py that will run on Jython 2.1. Here is a diff against the Python 2.3 version of sets.py. The changes were simple, but I may have made a mistake here or there,...
11
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do...
14
by: Oleg | last post by:
Hello there: I've been trying to create two different sets of required fields in one form and to use a radiobutton as sort of a switcher between these sets. In my HTML form there are two...
13
by: Dan Tsafrir | last post by:
is the following code standard? (cleanly compiles under g++-4.0.2): struct Asc { bool operator()(int a, int b) {return a < b;} }; struct Des { bool operator()(int a, int b) {return b > a;} };...
5
by: Ada | last post by:
hello folks, just wanna get some feedback from someone here who has more experience. :-) i'm developing a small app that require searching for the highest index within a directory. i was...
11
by: John Salerno | last post by:
I'd like to compare the values in two different sets to test if any of the positions in either set share the same value (e.g., if the third element of each set is an 'a', then the test fails). I...
1
by: UJ | last post by:
I am doing development on a machine and everything was working fine. The name of the project was ECS to I made all my references as ~/ECS/... Worked great. Put it on the final server running...
5
by: bir | last post by:
I have a folder which contains the xml files with the word CICM in the filename (can also contain some other files) I need to search for all these xml files and create a single zip file for all...
1
by: JosAH | last post by:
Greetings, Introduction This week I'll write a bit about generics (those funny angular brackets). I need an example and decided to use sets and some of their operations. This weeks' article...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.