Πώς μπορούμε να διαγράψουμε άδειους φακέλους .
Imports
System.IO
Public Sub DelEmptyFolders(ByVal DirPath As String)
Dim SubDirs() As String = Directory.GetDirectories(DirPath)
Dim strDir As String
For Each strDir In SubDirs
DelEmptyFolders(strDir)
Next
If Directory.GetFiles(DirPath).Length + Directory.GetDirectories(DirPath).Length = 0 Then
Directory.Delete(DirPath)
Console.WriteLine("Διαγραφή φακέλου: " & DirPath)
End If
End Sub
Οπότε μπορούμε να κάνουμε κλήση της DelEmptyFolders μεθόδου π.χ. DelEmptyFolders ("C:\") για να διαγραφούν όλοι οι άδειοι φάκελλοι στό σύστημα