i delete a child folder wich works fine, but then after that i want to delete
the parent also and n ugly msgbox appears saying
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
Additional information: The process cannot access the file "c:\Documents and
Settings\Morne\FTPtest\fff" because it is being used by another process.
here is the code for the button and the del function
Function DelFolder(ByVal Path, ByVal FolderName)
' If Directory.Exists(Path & "\" & FolderName) Then
If Directory.Exists(Path) Then
Dim remDIR As DirectoryInfo
Dim parent As String
remDIR = Directory.GetParent(FolderName)
parent = remdir.FullName
ListBoxDIR.ClearSelected()
Directory.Delete(Path)
Application.DoEvents()
ListBoxDIR.Refresh()
ListBoxDIR.Path = parent
ListBoxFILE.Refresh()
Application.DoEvents()
ListBoxDIR = New Microsoft.VisualBasic.Compatibility.VB6.DirListBox
ListBoxFILE = New Microsoft.VisualBasic.Compatibility.VB6.FileListBo x
'ListBoxDIR.Path = remDIR
ListBoxDIR.Refresh()
ListBoxFILE.Refresh()
MsgBox("Directory deleted", MsgBoxStyle.Information)
ElseIf Directory.Exists(Path & "\" & FolderName) Then
Dim remDIR As String = ListBoxDIR.Path
Directory.Delete(Path & "\" & FolderName)
Application.DoEvents()
ListBoxDIR = New Microsoft.VisualBasic.Compatibility.VB6.DirListBox
ListBoxFILE = New Microsoft.VisualBasic.Compatibility.VB6.FileListBo x
'ListBoxDIR.Path = remDIR
ListBoxDIR.Refresh()
ListBoxFILE.Refresh()
MsgBox("Directory deleted", MsgBoxStyle.Information)
Else
MsgBox("This directory does not exists", MsgBoxStyle.Exclamation)
End If
End Function
Private Sub cmdLdelFOLDER_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLdelFOLDER.Click
If ListBoxDIR.SelectedItem Is Nothing Then
MsgBox("You must first select a location", MsgBoxStyle.Exclamation)
Else
Dim Folder As String
Dim path As String
ListBoxDIR.Refresh()
path = ListBoxDIR.Path
Folder = ListBoxDIR.Path
DelFolder(path, Folder)
ListBoxDIR.Update()
ListBoxDIR.Refresh()
Application.DoEvents()
End If
End Sub
now by the look of it you might see that i tried a few things and yeah i
think there is i very easy way, BUT HOW, that is the question that i'm asking
you. Pleas help me i dont have any hair left and still need to program for
another 20 years or so.