Now, if you copy a file from "My Documents" into "Your Documents", a Created event will be raised by FileSystemWatcher2, but no event is raised for FileSystemWatcher1. FileSystemWatcher1 is set to watch "C:\My Documents", and FileSystemWatcher2 is set to watch "C:\Your Documents". For example, you create two instances of FileSystemWatcher. If the directory from which you copied was being watched by another instance of FileSystemWatcher, no event would be raised. When you copy a file or directory, the system raises a Created event in the directory to which the file was copied, if that directory is being watched. Some common occurrences, such as copying or moving a file or directory, do not correspond directly to an event, but these occurrences do cause events to be raised.
Private Sub OnRenamed( ByVal source As Object, ByVal e As RenamedEventArgs)Ĭonsole.WriteLine( "File: ", e.OldFullPath, e.FullPath) Private Sub OnChanged( ByVal source As Object, ByVal e As FileSystemEventArgs) Private Sub OnCreated( ByVal source As Object, ByVal e As FileSystemEventArgs)ĭebug.Print( "File: " & e.FullPath & " " & e.ChangeType)Ĭonsole.WriteLine( "Arxiu: " & e.FullPath) Watcher.NotifyFilter = NotifyFilters.CreationTimeĪddHandler watcher.Changed, AddressOf OnChangedĪddHandler watcher.Created, AddressOf OnChangedĪddHandler watcher.Deleted, AddressOf OnChangedĪddHandler watcher.Renamed, AddressOf OnRenamed "FROM CargaProcesos P INNER JOIN cargaficheros F on P.idproceso = F.idproceso " & _ĭim oComm As SqlCommand = New SqlCommand(sSql, oSQLConn)ĭim oReader As SqlDataReader = oComm.ExecuteReader() SSql = "SELECT P.IDPROCESO AS UNO,P.PROCESO,P.RUTA,P.RUTABAK,F.IDFICHERO,F.FICHERO,F.TIPOFICHERO " & _ Thanks a lot DMAN1 for that, but I had acquired from another place the code.Īnyway, I don't get the point with its behaviour's events, I mean, when I copy a file to specified folder (c:\p3) system doesn't raise oncreated event but the rest ones but never oncreate. Private Sub FSW_Renamed ( ByVal sender As Object, ByVal e As System. Private Sub FSW_Error ( ByVal sender As Object, ByVal e As System. Private Sub FSW_Disposed ( ByVal sender As Object, ByVal e As System.
Private Sub FSW_Deleted ( ByVal sender As Object, ByVal e As System. Private Sub FSW_Created ( ByVal sender As Object, ByVal e As System. Private Sub FSW_Changed ( ByVal sender As Object, ByVal e As System.
MyDocuments )įriend WithEvents FSW As New FileSystemWatcher ( TheUNCPath, TheFileFilter ) use the filesystemwatcher class and respond to it's events:ĭim TheUNCPath As String = Environment.