danielkelly
IS-IT--Management
Hi,
Im after some advice on how to handle my Text File Operations. I have a Windows Service that writes log information to a text File. Events such as Service Stop / Start, Diagnostic Information etc.
My question is should I open the log file and keep it open while the service is running and just keep adding to it using the Streamwriter methods, then close the file on the Service Stop Event. Or it is best practice to open the file, write the data and then close the file gain and then repeat for each operation, hence not needing to close the file on service stop.
Thanks in advance
Daniel.
Im after some advice on how to handle my Text File Operations. I have a Windows Service that writes log information to a text File. Events such as Service Stop / Start, Diagnostic Information etc.
My question is should I open the log file and keep it open while the service is running and just keep adding to it using the Streamwriter methods, then close the file on the Service Stop Event. Or it is best practice to open the file, write the data and then close the file gain and then repeat for each operation, hence not needing to close the file on service stop.
Thanks in advance
Daniel.