How to get the "Max" filenmae in a directory?

G

Guest

I need to find the file and its file name in a directory where the filename
is made up with XXXYYYYMMDDXXX.mdb The date is embedded in the middle of the
file name. The prefix and postfix of "XXXXXX" are the same for each
filename. I'm looking for ways to get the file name of the most recent date.


Thanks, Alpha
 
P

Paul E Collins

Alpha said:
I need to find the [most recent] file name in a directory
where the filename is made up with
XXXYYYYMMDDXXX.mdb The date is embedded
in the middle of the file name.

You'll need to get them all (Directory.GetFiles), sort the list
(Array.Sort), and pick the first one. Fortunately, YYYYMMDD dates sort
so that the last in the list is the latest date.

P.
 
G

Guest

That worked great! Thank you very much for your help.

Regards,
Alpha

Paul E Collins said:
Alpha said:
I need to find the [most recent] file name in a directory
where the filename is made up with
XXXYYYYMMDDXXX.mdb The date is embedded
in the middle of the file name.

You'll need to get them all (Directory.GetFiles), sort the list
(Array.Sort), and pick the first one. Fortunately, YYYYMMDD dates sort
so that the last in the list is the latest date.

P.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top