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.FileSystemWatcher

        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.DirectoryName
            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.EnableRaisingEvents = True
            btnStartWatch.Enabled = False
            btnStopWatch.Enabled = True



        End If

       

    End Sub




    Private Sub logchange(ByVal source As Object, ByVal e As _
                    System.IO.FileSystemEventArgs)
        If e.ChangeType = IO.WatcherChangeTypes.Changed Then
            Me.txtDisplayFiles.Text &= e.Name & _
                                    " - modified" & Now & vbCrLf

        ElseIf e.ChangeType = IO.WatcherChangeTypes.Created Then
            Me.txtDisplayFiles.Text &= e.FullPath & _
                                     " - created" & vbCrLf

        ElseIf e.ChangeType = IO.WatcherChangeTypes.Deleted 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.EnableRaisingEvents = False
        btnStartWatch.Enabled = True
        btnStopWatch.Enabled = False
    End Sub
VBdotnet2005Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PockyMasterCommented:
If I look at your code I think you should OR your filters

WatchFolder.NotifyFilter = IO.NotifyFilters.DirectoryName
            WatchFolder.NotifyFilter = NotifyFilters.FileName
            WatchFolder.NotifyFilter = NotifyFilters.Attributes
becomes
WatchFolder.NotifyFilter = (IO.NotifyFilters.DirectoryName OR NotifyFilters.FileName OR  NotifyFilters.Attributes)

Try if you got all the filters you need

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VBdotnet2005Author Commented:
That works. Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.