0

I would like to force overwrite logdata to a CSV file. It might well be that another user is reading that file at the moment.

What give me the possibility take no care about this kind of locking and write in the file? Of course, the appended data should displayed after writing when the user close and open file again.

Maybe a useful information: Writing data would occur many times for a very short term.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • I guess that the user opens the file with something like `Notepad.exe` that not just opens it for reading but also for writing. Anyway, I don't think you can easily force to write to an open file but take a look at the [Log-Entry](https://stackoverflow.com/a/44265303/1701026) that buffers the entries to be written until the concerned log file is writable again. – iRon Dec 01 '17 at 09:25
  • Locked file is locked. Either forcibly close the handle the other party has on the file (might cause data loss on their end, or wait and retry. For further help you need to provide more details (how the file is opened, your code for writing to the file, errors you're getting, ...). – Ansgar Wiechers Dec 01 '17 at 11:57

0 Answers0