Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

searching error files based on time.

Status
Not open for further replies.

UZN

Programmer
Oct 15, 2010
5
US
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.

Code:
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" & tempDim 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 fileArray2.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
 
Can i use datedifference functions for Arrays? the directory info is in Array.
 
You would use the DateDiff function in this line of code:
Code:
If fileArray2.CreationTime.Date <= curTime Then
.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top