Hi,
Watch the directories parent for the directory being delete.
Simple example needs 2 buttons (btnDelete and btnAdd), a filesystemwatch er,
and listbox.
Imports System.IO
Public Class Form1
Inherits System.Windows. Forms.Form
#Region " Windows Form Designer generated code "
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Directory.Creat eDirectory("C:\ Watch me")
FileSystemWatch er1.Path = "C:\Watch me"
FileSystemWatch er1.IncludeSubd irectories = True
End Sub
Private Sub FileSystemWatch er1_Created(ByV al sender As Object, ByVal e
As System.IO.FileS ystemEventArgs) Handles FileSystemWatch er1.Created
Dim strOut As String
strOut = String.Format(" Created {0}", e.Name)
ListBox1.Items. Add(strOut)
End Sub
Private Sub btnAdd_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles btnAdd.Click
Try
Directory.Creat eDirectory("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.EventArg s) Handles btnDelete.Click
Try
Directory.Delet e("C:\Watch me\Delete me")
Catch ex As Exception
End Try
End Sub
Private Sub FileSystemWatch er1_Deleted(ByV al sender As Object, ByVal e
As System.IO.FileS ystemEventArgs) Handles FileSystemWatch er1.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******** ******@TK2MSFTN GP14.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***@bellsout h.net> wrote in message
news:OB******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP15.phx.gbl... > .2003 have a filesystemwatch er ...
>
> does it have a directorysystem watcher ? What i need is to watch whether
> directory is deleted ?
>
> i assume filesystemwatch er delete method is for file, not directory.
>
> Pls advise
>
>