Problem with service and blocked txt o_O

  • Thread starter Thread starter MrS4T4n
  • Start date Start date
M

MrS4T4n

Hi!
I wrote a windows service, this service read a txt file and make some
task... the service works at 00:00, 00:30, 01:00, 01:30 etc... (every
half hour)

The problem is the txt, there is a dataloger that writes on it every 10
minutes, the dataloger and the service dont run at the same time, i.e:
Service: 00:00, 00:30, 01:00, 01:30 etc...
Dataloger: 00:05, 00:15, 00:25, 00:35 etc...

This works fine 3 or 4 times and then the dataloger crash with an I/O
error, can't write the txt file because the service had it blocked...
and i dont know what the hell is blocked the txt, i close the reader,
set it to nothing, call .finalize and

Try
srLector = New StreamReader(_File)
Catch ex As System.IO.IOException
EventLog1.WriteEntry("Error: " & ex.ToString)
End Try
..
..
srLector.DiscardBufferedData()
srLector.BaseStream.Close()
srLector.Close()
srLector = Nothing
..
..
Me.Finalize() ' when all the work is done...

I even try to copy the file and work with the copy but it crashes the
same way...
I know the problem is with the service, because it happens even when
the dataloger is not running, so PLEASE! if anyone knows what happend
write me a letter

Thanks in advance...
Jes
 
Do you write to the file? If not, make sure you open the file and
don't lock it. Then the other program can access it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top