Hack Forums
[.NET] FileSystemWatcher - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] FileSystemWatcher (/showthread.php?tid=4990623)



FileSystemWatcher - FluffyMcFluff - Sep 17, 2015

[Solved]
  • Had to put IncludeSub Directory's to True



I have a FileSystemWatcher ( fsw1 )
And
  • Listbox 1

  • Listbox 2

  • Listbox 3

  • Listbox 4

  • Textbox1 ( Enter Path of location )

  • FolderBrowserDialog1 ( fbd1 )

  • Button1 ( Browse for path )



My Full Code :

PHP Code

<?php 
Public Class Form1

    
Private Sub fsw1_Renamed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles Fsw1.Renamed

      ListBox1
.Items.Add("File- " & e.FullPath.ToString & " renamed at: " & System.DateTime.Now)

    
End Sub
    
Private Sub fsw1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles Fsw1.Created

      ListBox2
.Items.Add("File- " & e.FullPath.ToString & " created at: " & System.DateTime.Now)

    
End Sub
    
Private Sub fsw1_Deleted(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles Fsw1.Deleted
      ListBox3
.Items.Add("File- " & e.FullPath.ToString & " deleted at: " & System.DateTime.Now)
    
End Sub
    
Private Sub fsw1_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles Fsw1.Changed
      ListBox4
.Items.Add("File- " & e.FullPath.ToString & " modified at: " & System.DateTime.Now)
    
End Sub

    
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

      fbd1
.ShowDialog()

      
TextBox1.Text = fbd1.SelectedPath

      Fsw1
.Path = TextBox1.Text

      MsgBox
("Path to monitor is now set to: " & TextBox1.Text)

    
End Sub

End 
Class 

The problem i have is with Changed events whenever I edit a text file it doesnt show "test.txt" has been edited just shows file "Test" has been modified is their anyway to do this ?


* - Jackie Chun - Sep 17, 2015

What is E, it's a tree view? Fullpath obviously doesn't return the file extension.

I don't have Visual Studio on me at the moment but try looking through the suggested codes, there is probably one that makes sense to give you your File Extension.


* - FluffyMcFluff - Sep 17, 2015

(Sep 17, 2015 10:27 AM)Jackie Chun Wrote:  What is E, it's a tree view? Fullpath obviously doesn't return the file extension.

I don't have Visual Studio on me at the moment but try looking through the suggested codes, there is probably one that makes sense to give you your File Extension.
Thanks for you're reply I managed to fix it now I had Include Sub Directory's to False