Dears,
i have a product that write the alerts on a text file, i want to create an application to read these logs, and i want to empty this file if it reach 2G in size the problem is that i am afraid that at the moment of deletion process the product write at the file and i loss this alert.
Do you have any suggestions please ?
VulpesPosted Sep 16, 2012, 10:51 AM
http://www.c-sharpcorner.com/Forums/Thread/186699/rename-text-file-used-by-two-applications.aspx
However, I am sympathetic to the point being made by theLizard. Are you sure that the application doesn't have its own mechanism for dealing with files which get too large?
theLizardPosted Sep 16, 2012, 6:29 AM
You should NOT be deleting files that you are not in control of because you have no idea what the application writing the file is doing.
VulpesPosted Sep 14, 2012, 6:49 PM
Check out these links:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(VS.100).aspx
http://www.blackwasp.co.uk/FileSystemWatcher.aspx
Areeb AsadPosted Sep 14, 2012, 6:31 AM
VulpesPosted Sep 14, 2012, 5:26 AM
That, of course, means that you need to know the length in bytes of the next alert (say 'lenAlert') and then delete the file if it's already at least equal to (2 GB - lenAlert) bytes in size.