MS Folderwatcher
This commit is contained in:
@@ -16,23 +16,29 @@ Public Class ClassFolderwatcher
|
||||
End Sub
|
||||
|
||||
Public Function Restart_FolderWatch() As Boolean
|
||||
Try
|
||||
If FWFolderWatcher.EnableRaisingEvents = True Then
|
||||
'Gestartet also Stoppen
|
||||
FWFolderWatcher.EnableRaisingEvents = False
|
||||
My.Application.Globix.Folderwatchstarted = False
|
||||
If Directory.Exists(My.Application.Globix.CurrentFolderWatchPath) Then
|
||||
Try
|
||||
If FWFolderWatcher.EnableRaisingEvents = True Then
|
||||
'Gestartet also Stoppen
|
||||
FWFolderWatcher.EnableRaisingEvents = False
|
||||
My.Application.Globix.Folderwatchstarted = False
|
||||
|
||||
FWFolderWatcher = StartFolderwatcherForPath(My.Application.Globix.CurrentFolderWatchPath)
|
||||
My.Application.Globix.Folderwatchstarted = True
|
||||
My.UIConfig.Globix.FolderWatchStarted = True
|
||||
My.UIConfigManager.Save()
|
||||
End If
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Info($"Error in Restart_FolderWatch: {ex.Message}")
|
||||
Logger.Error(ex.Message)
|
||||
FWFolderWatcher = StartFolderwatcherForPath(My.Application.Globix.CurrentFolderWatchPath)
|
||||
My.Application.Globix.Folderwatchstarted = True
|
||||
My.UIConfig.Globix.FolderWatchStarted = True
|
||||
My.UIConfigManager.Save()
|
||||
End If
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Info($"Error in Restart_FolderWatch: {ex.Message}")
|
||||
Logger.Error(ex.Message)
|
||||
Return False
|
||||
End Try
|
||||
Else
|
||||
Logger.Info($"Attention: Check the fodlerwatchinit-Module...My.Application.Globix.CurrentFolderWatchPath is not existing [{My.Application.Globix.CurrentFolderWatchPath}]")
|
||||
Return False
|
||||
End Try
|
||||
End If
|
||||
|
||||
End Function
|
||||
Public Sub Restart_FolderWatchSCAN()
|
||||
Try
|
||||
@@ -53,7 +59,7 @@ Public Class ClassFolderwatcher
|
||||
End Sub
|
||||
Public Function StartStop_FolderWatch()
|
||||
Try
|
||||
If FWFolderWatcher Is Nothing OrElse FWFolderWatcher.EnableRaisingEvents = False Then
|
||||
If FWFolderWatcher Is Nothing Then 'OrElse FWFolderWatcher.EnableRaisingEvents = False
|
||||
' Folderwatch neu instanzieren
|
||||
FWFolderWatcher = StartFolderwatcherForPath(My.Application.Globix.CurrentFolderWatchPath)
|
||||
My.Application.Globix.Folderwatchstarted = True
|
||||
@@ -132,13 +138,13 @@ Public Class ClassFolderwatcher
|
||||
End Function
|
||||
|
||||
Private Function StartFolderwatcherForPath(pPath As String) As FileSystemWatcher
|
||||
Logger.Debug("Folder Watcher starting up for Path [{0}]", pPath)
|
||||
Dim oWatcher = New FileSystemWatcher(pPath, "*.*") With {
|
||||
.IncludeSubdirectories = False,
|
||||
.EnableRaisingEvents = True
|
||||
}
|
||||
AddHandler oWatcher.Created, AddressOf OnCreated
|
||||
Logger.Debug("Folder Watcher started for Path [{0}]", pPath)
|
||||
|
||||
Return oWatcher
|
||||
End Function
|
||||
|
||||
|
||||
Reference in New Issue
Block a user