grazie al suggerimento di
@LucaMs sono a buon punto,
sto provando questo metodo che se passo una sola cartella per analizzare eventuali cambiamenti funziona,
se passo piu cartelle separate dall "," purtroppo mi va in errore.
come posso passare i parametri corretti a questa semplice classe...
Grazie
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Dim cfw As CustomFileWatcher
End Sub
Sub AppStart (Args() As String)
cfw.Initialize("C:/syspc/dbcasse", Me, "CustomFileWatcherEvent") ' OK'
' questo mi da errore '
'' cfw.Initialize("C:/syspc/dbcasse,c:/pippo", Me, "CustomFileWatcherEvent")
StartMessageLoop
End Sub
Sub CustomFileWatcherEvent_CreationDetected(PathToWatch As String, Filename As String)
Log("New file/folder created: " & PathToWatch & "/" & Filename)
End Sub
Sub CustomFileWatcherEvent_ModificationDetected(PathToWatch As String, Filename As String)
Log("Modifica File : " & PathToWatch & "/" & Filename)
End Sub
Sub CustomFileWatcherEvent_DeletionDetected(PathToWatch As String, Filename As String)
Log("Cancellazione File : " & PathToWatch & "/" & Filename)
End Sub
la classe:
#Event: CreationDetected(PathToWatch As String, Filename As String)
#Event: DeletionDetected(PathToWatch As String, Filename As String)
#Event: ModificationDetected(PathToWatch As String, Filename As String)
Sub Class_Globals
Private FWatcher As FileWatcher
Private mEventName As String
Private mCallbackModule As Object
Private mPathToWatch As String
End Sub
'Initialze the object
'Pass the path you want to watch, the module you want to be called, the event you want to be called
Public Sub Initialize(PathToWatch As Object, CallbackModule As Object, EventName As String)
mEventName = EventName
mCallbackModule = CallbackModule
mPathToWatch=PathToWatch
FWatcher.Initialize("fwEvent")
FWatcher.SetWatchList(Array As String(mPathToWatch))
FWatcher.StartWatching
End Sub
Public Sub FermaAvviaVerifica( FermaAvvia As Boolean)
If FermaAvvia=False Then FWatcher.StopWatching Else FWatcher.StartWatching
End Sub
Public Sub PathControllo(mPath As Object)
mPathToWatch=mPath
FWatcher.StopWatching
FWatcher.SetWatchList(Array As String(mPathToWatch))
FWatcher.StartWatching
End Sub
Private Sub fwEvent_CreationDetected(FileName As String)
CallSub3(mCallbackModule, mEventName & "_CreationDetected", mPathToWatch, FileName)
Log("classe Creazione file")
End Sub
Private Sub fwEvent_DeletionDetected(FileName As String)
CallSub3(mCallbackModule, mEventName & "_DeletionDetected", mPathToWatch, FileName)
Log("classe Cancella file")
End Sub
Private Sub fwEvent_ModificationDetected(FileName As String)
CallSub3(mCallbackModule, mEventName & "_ModificationDetected", mPathToWatch, FileName)
Log("classe Modifica file")
End Sub
chi mi corregge questa classe...
grazie
Error: Illegal char <:> at index 18: C:/syspc/dbcasse,c:/pippo
java.nio.file.InvalidPathException: Illegal char <:> at index 18: C:/syspc/dbcasse,c:/pippo
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at butt.droid.FileWatcher$WatcherThread.run(FileWatcher.java:355)