Sorting files with the same first 3 letters, than deleting the older files?
<p>I had a question last week, and you quickly alleviated any concern that it would roadblock me, hoping that you can help a beginner program once more!</p>

<p>I'm trying to automate one of my daily mundane tasks and it's being quite a bugger, I think mainly because I'm not taking the correct approach.</p>

<p>Each morning I go through a system directory that houses many files with the same prefix, and a generated number following it. I have to sort alphabetically first, then remove the oldest versions of that file.</p>

<p>Here's an example pic of my directory: <a href="http://i.imgur.com/5l2Am.png" rel="nofollow">http://i.imgur.com/5l2Am.png</a></p>

<p>I was going to approach this situation by just sorting the files by name and comparing the first 3 letters to the following file, and if they were identical I would delete (or move to a backup folder) the second file, until they didn't match any longer, and I would move onto the next prefix as the comparator.</p>

<p>The problem with this though I found, is that they aren't always sorted correctly, and I risk deleting the wrong files.</p>

<p>Has anyone had experience with something of this nature? In my head and on VS I can put the pieces all there, but just can't seem to link it together, mainly because I've never ventured into the system.IO class before, but I want to learn!</p>

<p>Any advice is appreciated, and if you want to see my futile attempts I'll gladly share them :P.</p>

<p>Thanks,
Nick</p>
