0

Hi,
I'm working on searching error files based on time.
I have 2 folders which have permanent and temporary error files in it, and the only difference between permanent and temporary error files is creation time. I’m searching for error files in these 2 folders and my search should only return permanent error files not the temporary ones. Here is the code snippet.

Dim searchDir2 As New IO.DirectoryInfo("C:\ERROR_FOLDER")
        Dim fileArray2 As IO.FileInfo() = searchDir2.GetFiles("*.error")



        Dim fileName2 As IO.FileInfo

        For Each fileName2 In fileArray2
            If fileName2.CreationTime.Date <= curTime Then
            temp = fileName2.Name
            temp3 = "C:\ _ERRORS" & temp

I’m working on the if statement but not able to get it working. i want the error files whose creation time is less than 1 hour of the current time. Any help is appreciated.

Thanks

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by uzn
0

I think you have to work with the hours part of the date. Something like
if fileName2.CreationTime.Hour <= Now.TimeofDay.Hours then
.....
...
end if
Try that!

0

I think you have to work with the hours part of the date. Something like
if fileName2.CreationTime.Hour <= Now.TimeofDay.Hours then
.....
...
end if
Try that!

This solved my problem:
If DateDiff(DateInterval.Hour, fileName2.CreationTime, now) > 1 Then

Thanks for your help again.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.