471,354 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

???Process still running???

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
0 1065

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Billg_sd | last post: by
77 posts views Thread by Charles Law | last post: by
4 posts views Thread by TieTo | last post: by
2 posts views Thread by Hayato Iriumi | last post: by
8 posts views Thread by Henrik | last post: by
3 posts views Thread by =?Utf-8?B?Q2hyaXM=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.