Finding files based on date and time

Hi,

Re: VB.net 2003

I was wondering if anyone knew of a way to find files in a specified location based on their date and time, without recursively having to loop round the directory and it's subs, checking each file individually.  I need to quickly put together a simple directory/file scan/backup app for a small network and would hope it can reasonably easily be accomplished using VB.NET

I've been through the help files and Google'd until I can Google no more and am now stumped.

Any and all replies appreciated.

Steven
onedunparkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vis781Commented:
I really don't think so. The date/time of when the file was created of modified is part of the file properties and is not stored anywhere else. Even the windows search assistant and to iterate throught the folders etc.
0
onedunparkAuthor Commented:
Thanks for the reply.  I had hoped against this and already have a straightforward recursive routne written.  I'd just like to have avoided it.

I'll hold off a wee bit to see if there are other replies and if not, the points are yours.

0
PockyMasterCommented:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim arFiles As ArrayList = FindFilesByDate("c:\program files", Now.AddDays(-10), Now)



    End Sub


    Public Function FindFilesByDate(ByVal Folder As String, ByVal dtStart As Date, ByVal dtEnd As Date) As ArrayList
        Dim arResult As New ArrayList

        For Each sFilename As String In My.Computer.FileSystem.GetFiles(Folder, FileIO.SearchOption.SearchAllSubDirectories, "*.*")

            Dim fi As New FileInfo(sFilename)
            If fi.LastWriteTime <= dtEnd And fi.LastWriteTime >= dtStart Then
                arResult.Add(sFilename)
            End If

        Next

        Return arResult
    End Function

This works in Visual Studio 2005, but somehow it doesnt seem faster to me than iterating yourself :D
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.