VBdotnet2005
asked on
FSW
Why my Me.txtDisplayFiles.Text does not display the path, name and time when a new file is added. It says only "modifiled"
Private Sub btnStartWatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartWatch.Click
WatchFolder = New System.IO.FileSystemWatche r
If Me.txtWatchPath.Text = Nothing Then
MessageBox.Show("Please check file path ", "Path " & Now, MessageBoxButtons.OK, _
MessageBoxIcon.Information )
Else
WatchFolder.Path = Trim(Me.txtWatchPath.Text)
WatchFolder.NotifyFilter = IO.NotifyFilters.Directory Name
WatchFolder.NotifyFilter = NotifyFilters.FileName
WatchFolder.NotifyFilter = NotifyFilters.Attributes
AddHandler WatchFolder.Changed, AddressOf logchange
AddHandler WatchFolder.Created, AddressOf logchange
AddHandler WatchFolder.Deleted, AddressOf logchange
AddHandler WatchFolder.Renamed, AddressOf logrename
WatchFolder.EnableRaisingE vents = True
btnStartWatch.Enabled = False
btnStopWatch.Enabled = True
End If
End Sub
Private Sub logchange(ByVal source As Object, ByVal e As _
System.IO.FileSystemEventA rgs)
If e.ChangeType = IO.WatcherChangeTypes.Chan ged Then
Me.txtDisplayFiles.Text &= e.Name & _
" - modified" & Now & vbCrLf
ElseIf e.ChangeType = IO.WatcherChangeTypes.Crea ted Then
Me.txtDisplayFiles.Text &= e.FullPath & _
" - created" & vbCrLf
ElseIf e.ChangeType = IO.WatcherChangeTypes.Dele ted Then
Me.txtDisplayFiles.Text &= e.FullPath & _
"- deleted" & vbCrLf
End If
End Sub
Public Sub logrename(ByVal source As Object, ByVal e As _
System.IO.RenamedEventArgs )
Me.txtDisplayFiles.Text &= "File" & e.OldName & _
" has been renamed to " & e.Name & vbCrLf
End Sub
Private Sub btnStopWatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStopWatch.Click
' Stop watching the folder
watchfolder.EnableRaisingE vents = False
btnStartWatch.Enabled = True
btnStopWatch.Enabled = False
End Sub
Private Sub btnStartWatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartWatch.Click
WatchFolder = New System.IO.FileSystemWatche
If Me.txtWatchPath.Text = Nothing Then
MessageBox.Show("Please check file path ", "Path " & Now, MessageBoxButtons.OK, _
MessageBoxIcon.Information
Else
WatchFolder.Path = Trim(Me.txtWatchPath.Text)
WatchFolder.NotifyFilter = IO.NotifyFilters.Directory
WatchFolder.NotifyFilter = NotifyFilters.FileName
WatchFolder.NotifyFilter = NotifyFilters.Attributes
AddHandler WatchFolder.Changed, AddressOf logchange
AddHandler WatchFolder.Created, AddressOf logchange
AddHandler WatchFolder.Deleted, AddressOf logchange
AddHandler WatchFolder.Renamed, AddressOf logrename
WatchFolder.EnableRaisingE
btnStartWatch.Enabled = False
btnStopWatch.Enabled = True
End If
End Sub
Private Sub logchange(ByVal source As Object, ByVal e As _
System.IO.FileSystemEventA
If e.ChangeType = IO.WatcherChangeTypes.Chan
Me.txtDisplayFiles.Text &= e.Name & _
" - modified" & Now & vbCrLf
ElseIf e.ChangeType = IO.WatcherChangeTypes.Crea
Me.txtDisplayFiles.Text &= e.FullPath & _
" - created" & vbCrLf
ElseIf e.ChangeType = IO.WatcherChangeTypes.Dele
Me.txtDisplayFiles.Text &= e.FullPath & _
"- deleted" & vbCrLf
End If
End Sub
Public Sub logrename(ByVal source As Object, ByVal e As _
System.IO.RenamedEventArgs
Me.txtDisplayFiles.Text &= "File" & e.OldName & _
" has been renamed to " & e.Name & vbCrLf
End Sub
Private Sub btnStopWatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStopWatch.Click
' Stop watching the folder
watchfolder.EnableRaisingE
btnStartWatch.Enabled = True
btnStopWatch.Enabled = False
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER