The below link is perhaps overkill for what you are trying to do, but CreationTime sort example is included (look at the second example of use):
http://vb2themax.com/ShowContent.aspx?ID=38f32e71-ab8e-449d-9557-8417bd31c350>I need to scan several directories containing about 10000 files each and for files created, say, more than 2 weeks ago during the day hours prior to the current time. There could be about 100 files that should be erased. With VFP ADIR() it is quite easy to do:
>
>If adir(atmp,”*.*”)>0
> =asort(atmp,3)
> ia=1
> do while atmp[ia,3]<date()-14
> if additional_timecondition
> erase (atmp[ia,1])
> endif
>
> ia=ia+1
>
> enddo
>endif
>
>
>And it takes about 1-5 seconds.
>
>But I cannot figure out how to do it wisely in VB.NET: the collection object like Scripting.FileSystemObject does not give the ability to sort. Therefore it requires scanning all the files, and checking the date of each of them. It takes about 2-3 minutes per directory.
>
>Adding the VFP Toolkit for .NET requires additional installation on the PC, and it is not allowed at the time.
>
>Has anyone a suitable solution?