I implemented this event of the FileSystemWatcher
:
Private Shared Sub OnCreated(source As Object, e As FileSystemEventArgs)
If e.Name.ToUpper() == "MYTEXTFILE.TXT" then
' code '
End If
End Sub
Is there a way to monitor if created files are in a textbox similar to this?
Private Shared Sub OnCreated(source As Object, e As FileSystemEventArgs)
If e.Name.ToUpper.contains(textbox1.text) then
' code '
End Sub
Having more than one file in a multiline textbox and every filename is in a separate line requires that you should split the filenames individually and then check each one with the file just created.
Private Shared Sub OnCreated(source As Object, e As FileSystemEventArgs)
' Get an array of the files at each line and remove eventually spurious empty lines
Dim files() = textbox1.Text.Split(New String() {Environment.NewLine}, _
StringSplitOptions.RemoveEmptyEntries)
Dim newFile = e.Name.ToUpper()
for each file in files
if file.ToUpper() = newFile Then
' code '
Exit For
End If
Next
End Sub