I have a form that checkes if there are some changes made in a folder. I do this with the FileSystemWatcher. When a change is notiyfied another form has to be loaded. The second form is loaded, but the controls are not visible. When I load the second form by clicking a button, the contols are visible. I think it's because of the If statement, but I don't know for sure. Can someone helpe me out with this?
Imports System.IO
'Imports System.Diagnostics
Public Class Settings
Public watchfolder As FileSystemWatcher
Private Sub Settings_Load(sender As Object, e As EventArgs) Handles MyBase.Load
txt_watchpath.Text = "D:\temp"
If txt_watchpath.Text = "" Then
btn_startwatch.Enabled = False
End If
End Sub
Private Sub txt_watchpath_TextChanged(sender As Object, e As EventArgs) Handles txt_watchpath.TextChanged
If Me.Text <> "" Then
btn_startwatch.Enabled = True
End If
End Sub
Private Sub btn_startwatch_Click(sender As Object, e As EventArgs) Handles btn_startwatch.Click
watchfolder = New System.IO.FileSystemWatcher()
'this is the path we want to monitor
watchfolder.Path = txt_watchpath.Text
'Add a list of Filter we want to specify
'make sure you use OR for each Filter as we need to
'all of those
watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or
IO.NotifyFilters.LastWrite
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or
IO.NotifyFilters.Attributes
' add the handler to each event
AddHandler watchfolder.Changed, AddressOf logchange
AddHandler watchfolder.Created, AddressOf logchange
'AddHandler watchfolder.Deleted, AddressOf logchange
' add the rename handler as the signature is different
AddHandler watchfolder.Renamed, AddressOf logrename
'Set this property to true to start watching
watchfolder.EnableRaisingEvents = True
watchfolder.IncludeSubdirectories = False
btn_startwatch.Enabled = False
btn_stop.Enabled = True
Me.Hide()
'End of code for btn_start_click
End Sub
Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
If e.ChangeType = IO.WatcherChangeTypes.Changed Then
FrmPopup.Fullpath = e.FullPath
FrmPopup.Activity = e.Name & " is changed"
FrmPopup.Show()
End If
If e.ChangeType = IO.WatcherChangeTypes.Created Then
FrmPopup.Fullpath = e.FullPath
FrmPopup.Activity = e.Name & " is made"
test.Show()
End If
End Sub
Private Sub logrename(ByVal source As Object, ByVal e As System.IO.RenamedEventArgs)
FrmPopup.Fullpath = e.FullPath
FrmPopup.Activity = e.OldName & " is changed to " & e.Name
FrmPopup.Show()
End Sub
Private Sub btn_stop_Click(sender As Object, e As EventArgs) Handles btn_stop.Click
FrmPopup.Show()
End Sub
End Class