[COLOR=#1000a0]Private[/COLOR] [COLOR=#1000a0]Shared[/COLOR] [COLOR=#1000a0]Sub[/COLOR] [B]DeleteDirectoryInternal[/B]([COLOR=#1000a0]ByVal[/COLOR] [B]directory[/B][COLOR=#1000a0] As [/COLOR][URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=1"]String[/URL], [COLOR=#1000a0]ByVal[/COLOR] [B]onDirectoryNotEmpty[/B][COLOR=#1000a0] As [/COLOR][URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=2"]DeleteDirectoryOption[/URL], [COLOR=#1000a0]ByVal[/COLOR] [B]showUI[/B][COLOR=#1000a0] As [/COLOR][URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=3"]UIOptionInternal[/URL], [COLOR=#1000a0]ByVal[/COLOR] [B]recycle[/B][COLOR=#1000a0] As [/COLOR][URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=4"]RecycleOption[/URL], [COLOR=#1000a0]ByVal[/COLOR] [B]onUserCancel[/B][COLOR=#1000a0] As [/COLOR][URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=5"]UICancelOption[/URL])
[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=6"]FileSystem[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=7"]VerifyDeleteDirectoryOption[/URL]([COLOR=#800000]"onDirectoryNotEmpty"[/COLOR], [URL="http://www.vbdotnetforums.com/"]onDirectoryNotEmpty[/URL])
[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=8"]FileSystem[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=9"]VerifyRecycleOption[/URL]([COLOR=#800000]"recycle"[/COLOR], [URL="http://www.vbdotnetforums.com/"]recycle[/URL])
[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=10"]FileSystem[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=11"]VerifyUICancelOption[/URL]([COLOR=#800000]"onUserCancel"[/COLOR], [URL="http://www.vbdotnetforums.com/"]onUserCancel[/URL])
[COLOR=#1000a0]Dim[/COLOR] [B]text1[/B] [COLOR=#1000a0]As[/COLOR] [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=12"]String[/URL] = [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=13"]Path[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=14"]GetFullPath[/URL]([URL="http://www.vbdotnetforums.com/"]directory[/URL])
[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=15"]FileSystem[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=16"]DemandDirectoryPermission[/URL]([URL="http://www.vbdotnetforums.com/"]text1[/URL], [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=17"]FileIOPermissionAccess[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=18"]Write[/URL])
[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=19"]FileSystem[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=20"]ThrowIfDevicePath[/URL]([URL="http://www.vbdotnetforums.com/"]text1[/URL])
[COLOR=#1000a0]If[/COLOR] [COLOR=#1000a0]Not[/COLOR] [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=21"]Directory[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=22"]Exists[/URL]([URL="http://www.vbdotnetforums.com/"]text1[/URL]) [COLOR=#1000a0]Then[/COLOR]
[COLOR=#1000a0]Throw[/COLOR] [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=23"]ExceptionUtils[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=24"]GetDirectoryNotFoundException[/URL]([COLOR=#800000]"IO_DirectoryNotFound_Path"[/COLOR], [COLOR=#1000a0]New[/COLOR] [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=25"]String[/URL]() { [URL="http://www.vbdotnetforums.com/"]directory[/URL] })
[COLOR=#1000a0]End If[/COLOR]
[COLOR=#1000a0]If[/COLOR] [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=26"]FileSystem[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=27"]IsRoot[/URL]([URL="http://www.vbdotnetforums.com/"]text1[/URL]) [COLOR=#1000a0]Then[/COLOR]
[COLOR=#1000a0]Throw[/COLOR] [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=28"]ExceptionUtils[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=29"]GetIOException[/URL]([COLOR=#800000]"IO_DirectoryIsRoot_Path"[/COLOR], [COLOR=#1000a0]New[/COLOR] [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=30"]String[/URL]() { [URL="http://www.vbdotnetforums.com/"]directory[/URL] })
[COLOR=#1000a0]End If[/COLOR]
[COLOR=#1000a0]If[/COLOR] (([URL="http://www.vbdotnetforums.com/"]showUI[/URL] <> [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=31"]UIOptionInternal[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=32"]NoUI[/URL]) [COLOR=#1000a0]AndAlso[/COLOR] [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=33"]Environment[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=34"]UserInteractive[/URL]) [COLOR=#1000a0]Then[/COLOR]
[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=35"]FileSystem[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=36"]ShellDelete[/URL]([URL="http://www.vbdotnetforums.com/"]text1[/URL], [URL="http://www.vbdotnetforums.com/"]showUI[/URL], [URL="http://www.vbdotnetforums.com/"]recycle[/URL], [URL="http://www.vbdotnetforums.com/"]onUserCancel[/URL], [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=37"]FileOrDirectory[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=38"]Directory[/URL])
[COLOR=#1000a0]Else[/COLOR]
[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=39"]Directory[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=40"]Delete[/URL]([URL="http://www.vbdotnetforums.com/"]text1[/URL], ([URL="http://www.vbdotnetforums.com/"]onDirectoryNotEmpty[/URL] = [URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=41"]DeleteDirectoryOption[/URL].[URL="http://www.aisto.com/roeder/dotnet/Default.aspx?Object=42"]DeleteAllContents[/URL]))
[COLOR=#1000a0]End If[/COLOR]
[COLOR=#1000a0]End Sub[/COLOR]