
Now the program in working! Thank you MPelletier and Plutonix for the amazing help! Here is the complete code: Imports System.IO Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Writer.WriteLine(Chr(13) & "File" + " " + e.FullPath + "has been renamed to" + " " + e.Name) Public Sub logrename(ByVal source As Object, ByVal e As _ Writer.WriteLine(Chr(13) & "Filde" + " " + e.FullPath + " " + "has been deleted") If e.ChangeType = IO.WatcherChangeTypes.Deleted Then Writer.WriteLine(Chr(13) & "File" + " " + e.FullPath + " " + "has been created") If e.ChangeType = IO.WatcherChangeTypes.Created Then Writer.WriteLine(Chr(13) & "File" + " " + e.FullPath + " " + "has been modified") If e.ChangeType = IO.WatcherChangeTypes.Changed Thenĭim writer As New IO.StreamWriter("log.txt") Private Sub logchange(ByVal source As Object, ByVal e As _ 'Set this property to true to start watching ' add the rename handler as the signature is differentĪddHandler watchfolder.Renamed, AddressOf logrename Watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _ĪddHandler watchfolder.Changed, AddressOf logchangeĪddHandler watchfolder.Created, AddressOf logchangeĪddHandler watchfolder.Deleted, AddressOf logchange Watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName 'make sure you use OR for each Filter as we need to

Watchfolder = New System.IO.FileSystemWatcher() Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Can someone help me with this problem? Here's the code: Imports System.IO
#Vb.net file monitor watcher change journal code#
I've writed the code to make a new line when another change is made, when a change is made, it writes it down to a file named log.txt, but the log only looks like "File log.txt has been modified" because the program, when it write changes to the log, it changes the log.txt to write down the log, but the strange is, it deletes everything in the document and writes "File log.txt has been modified" even if I have writed in the code to make a new line before writing. when a file deletes, when a file renames, when a file creates and which files, but it's a problem. I've made a program in Visual Basic 2010, that monitors and write down changes in a folder eg.
