Hi,
Watch the directories parent for the directory being delete.
Simple example needs 2 buttons (btnDelete and btnAdd), a filesystemwatcher,
and listbox.
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Directory.CreateDirectory("C:\Watch me")
FileSystemWatcher1.Path = "C:\Watch me"
FileSystemWatcher1.IncludeSubdirectories = True
End Sub
Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e
As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
Dim strOut As String
strOut = String.Format("Created {0}", e.Name)
ListBox1.Items.Add(strOut)
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
Directory.CreateDirectory("C:\Watch me\Delete me")
Catch ex As Exception
End Try
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
Try
Directory.Delete("C:\Watch me\Delete me")
Catch ex As Exception
End Try
End Sub
Private Sub FileSystemWatcher1_Deleted(ByVal sender As Object, ByVal e
As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Deleted
Dim strOut As String
strOut = String.Format("Deleted {0}", e.Name)
ListBox1.Items.Add(strOut)
End Sub
End Class
Ken