Hi There,

Proberly a really simple request but im desperate for help none the same lol,

I need to write some code that, takes filenames from a folder, and displays them in an order in a list. (Im using Visual Studio btw) lol.

The file names are in the format of

bghtyhgfr5674456_120411_3215.

The last four digits the time, middle set the date. Currently my code can read these file names and saves them as strings however i need to display them in time/date order, most recent first.

What is the best way to go about this?

Thanks in advance
James

the best option would be to use the string split method as ddanbe suggested,
when you do so, instead of an array size of 3 that you expect it to be, you would also get a empty string array at index 0, may be u can use the trim method or make sure you handle that in the loop.


bghtyhgfr5674456_120411_3215.

The last four digits the time, middle set the date.

How is 3215 the time?? What it represents? Seconds?
Because 32hours and 15 minutes cannot be in one day!

A simple Split is fine if all you have to do is split at the underscores and pass the parts off to date/time parsers, but it starts to get messy if you have to do more text manipulation after the split.

This might be slightly overkill for the posted problem, but I suggest you become familiar with regular expressions (if you aren't already) as something to keep in mind for when you have to parse formatted text that isn't dead simple.

This article has been dead for over six months. Start a new discussion instead.