File enumeration scenario help

fiddy

Member
Joined
Jun 18, 2007
Messages
11
Location
Melbourne, Australia
Programming Experience
5-10
I have the following scenario;
- a console app that is combining pdf docs into one large one
- i need it to be black box - ie, pass it a folder with a bunch of files and then have it combine them together
- the folder may contain 10 files, but only need to process 5 of them - so i was thinking of simply numbering them when they are moved to the folder for combining.

So basically what i need is to loop through all the files in the directory and if they are named using a certain numbering scheme, add them to the main combined file.

I initially thought to named them 1 thru 10 (for example) then have a counter and check the filename against that counter. Problem i realise is that if the directoryInfo returns them unordered, it will not combine them correctly.

In any event - its a pretty simple scenario, but looking for what is the best, cleanest way to accomplish.

Thx - i hope it makes sense what i'm after ..
 
Not sure i was clear - but i figured an easy way to do this would be to obtain an array of FileInfo objects, then sort those by name. Once sorted I can process the array one by one.

But does anyone have any sample sort code ? Links ?

Thx
 
Back
Top