.exes, :
FileSystemWatcher .exe , "Commands.txt"
FileSystemWatcher1.Path = Application.StartupPath
FileSystemWatcher1.NotifyFilter=NotifyFilters.LastWrite
FileSystemWatcher1.Filter = "Commands.txt"
FileSystemWatcher1.EnableRaisingEvents = True
To track / stop monitoring, set the path and the EnableRaisingEvents property to True or False
This is the event raised when the file changed:
Private Sub FileSystemWatcher1_Changed(sender As System.Object, e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
'Open the file and read the content.
'you can use your own commands
End Sub
This way you only get the event when the file changes, and you do not need to use timers or anything else.
In another .exe file, you just need to write the command or message that you want to send: This example records the current date and time, overwriting the file each time.
Dim Timestamp() As Byte = System.Text.Encoding.Default.GetBytes(Now.ToString)
Dim Fs As System.IO.FileStream
Fs = New System.IO.FileStream("Commands.txt", FileMode.Create, FileAccess.Write)
Fs.Write(Timestamp, 0, Timestamp.Length - 1)
Fs.Close()
Done!
source
share