Re: [2005] Delete old files
Something like this, but obviously you should test it out:
Code:
Dim files() As String = IO.Directory.GetFiles("C:\Temp\backup")
For Each f As String In files
Dim filenamedate As String = f.Substring(f.Length - 14, 10)
Dim dt As DateTime
If Date.TryParse(filenamedate, dt) AndAlso DateDiff(DateInterval.Month, Now.Date, dt.Date) < -5 Then
IO.File.Delete(f)
End If
Next
Re: [2005] Delete old files
Ah - I see what you've done there. Unforuntately, the files won't always be called the same :(
Can I get file attributes in vb.net? Eg the 'Created' date/time?
Re: [2005] Delete old files
Sure, you can use IO.File.GetCreationTime to get the creation time of a file.