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
--------------------
"James" <jk****@hotmail.com> wrote in message
news:uD**************@TK2MSFTNGP14.phx.gbl...
does it watch a directory being DELETED ?
i thot filewatch only watch FILES within subdirectory.
More concern is DIRECTORY itself being deleted.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OB**************@TK2MSFTNGP09.phx.gbl... Hi,
The filesystemwatch will watch directories.
http://msdn.microsoft.com/library/de...classtopic.asp
Ken
------------------
"James" <jk****@hotmail.com> wrote in message
news:OT**************@TK2MSFTNGP15.phx.gbl... > .2003 have a filesystemwatcher ...
>
> does it have a directorysystemwatcher ? What i need is to watch whether
> directory is deleted ?
>
> i assume filesystemwatcher delete method is for file, not directory.
>
> Pls advise
>
>