Using VB.Net 2005
I am trying to scan a folder and delete all subfolders and files if they are not certain 'required' folders from my app:
There are 3 folders that must always remain. Source code else where ensures that. The code I have keeps picking up the ones I want to remain and targets them for deletion, right along with the ones I do want gone.
It seems that my logic is flawed. Please help.
Public Sub cleandacrap()
Dim SourceDir As String = Application.StartupPath & "\MYAPP"
Dim source As DirectoryInfo = New DirectoryInfo(SourceDir)
Dim FiCurrent As String
Dim DiCurrent As String
If source.Exists Then
For Each DiCurrent In Directory.GetDirectories(SourceDir)
If DiCurrent <> "Projects" Or DiCurrent <> "Reports" Or DiCurrent <> "Volume Tables" Then ' this line does not work. I have wrote different ways but have yet to discover the 'right' way!
If MsgBox("about to delete folder " & DiCurrent, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Private Sub DelteFiles(ByVal dirname As String)
Dim Currentfile As String
Dim CurrentDirectory As String
For Each Currentfile In Directory.GetFiles(dirname)
For Each CurrentDirectory In Directory.GetDirectories(dirname)
DelteFiles(dirname + "\" + Path.GetFileName(CurrentDirectory))