I want to create a function which should delete all subfolders of a folder which are 10 days older.
Shell script to delete directories older than n days
I want show all the folder and count how much old and delete if it is 10 days old.
enter code here
Private Function test(ByVal directory As String) As String()
Dim fi As New IO.DirectoryInfo(directory)
Dim path() As String = {}
For Each subfolder As IO.DirectoryInfo In fi.GetDirectories()
Array.Resize(path, path.Length + 1)
path(path.Length - 1) = subfolder.FullName
For Each s As String In test(subfolder.FullName)
Array.Resize(path, path.Length + 1)
path(path.Length - 1) = s
Dim w = IO.Path.GetFileName(s)
'' ListBox1.Items.Add(w)
Dim iDate As String = w
Dim oDate As DateTime = Convert.ToDateTime(iDate)
''MsgBox(oDate.Day & " " & oDate.Month & " " & oDate.Year)
DateTimePicker1.Value = DateTime.Today
Dim date2 As Date = oDate
Dim span = DateTimePicker1.Value - date2
Dim days As Double = span.TotalDays
'' MsgBox(days)
'' ListBox1.Items.Add(days)
Next
Next
this part is not working
If days > 10 Then
fi.Delete()
End If