hello
is there a way to disable FileSystemWatcher after file is found?
beacuse it continues to loop.
this my code.
thanx for any help
salsa :)
is there a way to disable FileSystemWatcher after file is found?
beacuse it continues to loop.
this my code.
Code:
'in form load =====================================
Dim watched As String = Path.Combine("C:\ESystem\EOUT")
Dim fsw As New FileSystemWatcher(watched)
fsw.NotifyFilter = NotifyFilters.FileName Or NotifyFilters.LastWrite Or NotifyFilters.CreationTime
fsw.EnableRaisingEvents = True
fsw.Filter = "*.out"
AddHandler fsw.Created, AddressOf Fsw_Changed
Code:
Private Sub Fsw_Changed(ByVal sender As Object, ByVal e As FileSystemEventArgs)
Try
Call Readfile()
Catch ex As Exception
MessageBox.Show(ex.Message, "err", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Code:
Private Sub Readfile()
Dim line As String = String.Empty
Try
Using objReader As New StreamReader("C:\ESystem\EOUT\ECharge.out")
line = objReader.ReadLine
If Mid(line, 1, 3) = "000" Then
Dim EResultRecord As String = line
DialogResult = DialogResult.OK
Else
EResultRecord = 300
End If
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "err", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
salsa :)