ZorroRojo
Member
The following code works great the first time I run it.
The problem is if I have a file named test.txt created 10/10/2006 12:00PM and then I delete it and create a new one with the same name and then run the above code it still pulls back the create date of 10/10/2006 12:00PM even though the create date I see when looking at the file is 10/10/2006 12:01PM. I see the same thing if I created a file yesterday and delete it and then create one today. It will still use the create date and time from the file I created yesterday.
Does anyone know why this is happening? How can I make it find the correct creation date?
What I am simulating here is receiving a daily import but I never know when the new file will arrive and I want to make sure I don't process the same data more than once. So I have a process that checks each day starting at a certain time and if the date is for today then it imports the data. If the date is not todays then it reschedules itself to run 15 minutes later until a file with todays date is found.
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FileNames(New DirectoryInfo("c:\data"))
End Sub
Sub FileNames(ByVal dir As DirectoryInfo)
Dim objFile As FileInfo
For Each objFile In dir.GetFiles("*.txt")
Console.WriteLine(objFile.FullName & " " & objFile.CreationTime & " ")
Next
End Sub
The problem is if I have a file named test.txt created 10/10/2006 12:00PM and then I delete it and create a new one with the same name and then run the above code it still pulls back the create date of 10/10/2006 12:00PM even though the create date I see when looking at the file is 10/10/2006 12:01PM. I see the same thing if I created a file yesterday and delete it and then create one today. It will still use the create date and time from the file I created yesterday.
Does anyone know why this is happening? How can I make it find the correct creation date?
What I am simulating here is receiving a daily import but I never know when the new file will arrive and I want to make sure I don't process the same data more than once. So I have a process that checks each day starting at a certain time and if the date is for today then it imports the data. If the date is not todays then it reschedules itself to run 15 minutes later until a file with todays date is found.