Todd MacPherson
asked on
Need code to delete folder, files, and subfolders
Hi
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.
I have
'delete all user created tab folders and their contents
Dim SourceDir As String = Application.StartupPath & "\Projects\" & clsGlobals.Form2.lblProjNa me.Text & "\Tabs" & "\" & TabControl1.SelectedTab.Te xt & ""
Dim source As DirectoryInfo = New DirectoryInfo(SourceDir)
If source.Exists Then
source.Delete()
End If
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.
Thanks
PBLack
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.
I have
'delete all user created tab folders and their contents
Dim SourceDir As String = Application.StartupPath & "\Projects\" & clsGlobals.Form2.lblProjNa
Dim source As DirectoryInfo = New DirectoryInfo(SourceDir)
If source.Exists Then
source.Delete()
End If
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.
Thanks
PBLack
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER