datetime

  • Thread starter Thread starter BRIAN
  • Start date Start date
B

BRIAN

I am tyrying to use the System.IO.File.GetCreationTime
name space to get the creation date of a file. That's no
problem.

I want to delete a file if it is older than two weeks.

For Each File1 In Directory.GetFiles("c:\Test")
If CreationDate < (System.DateTime.Now( ) - 14) Then
File.Delete(File1)
End If
Next

my error is at (system.datetime.now() - 14)

says operator '-' is not defined for datetime or integer.

Does anyone know how to subtract a number of days from a
date that is not in datetime format?

Thanks
 
Hi Brian,

Try:
If System.DateTime.Now.Subtract(CreationDate).Days > 14

Alex Papadimoulis
 
Hi,
Try using DateTime class. It has methods like Add Days. try adding in -14 to
now and then compare it with CreationDate.

Chao,
Hermit Dave
 
Back
Top