By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,784 Members | 3,536 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,784 IT Pros & Developers. It's quick & easy.

???Process still running???

P: n/a
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.
Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.