Need code to delete folder, files, and subfolders
Posted on 2007-04-05
USING VB.NET 2003
I am trying to write some code to delete the main folder and all of its contents - files and subfolders sub-subfolders etc.
'delete all user created tab folders and their contents
Dim SourceDir As String = Application.StartupPath & "\Projects\" & clsGlobals.Form2.lblProjName.Text & "\Tabs" & "\" & TabControl1.SelectedTab.Text & ""
Dim source As DirectoryInfo = New DirectoryInfo(SourceDir)
If source.Exists Then
Thinking that it would do the trick but it crashes because the folder is not empty. So How do I get it to drill down through the main folder and wipe everything out? Have tinkered a bit but got nowhere.