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 ?

VulpesRank #55 · 29.2K reputationPosted Sep 14, 2012, 1:26 AM EDT
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.
Areeb Asad5 reputationPosted Sep 14, 2012, 2:31 AM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 14, 2012, 2:49 PM EDT
Check out these links:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(VS.100).aspx
http://www.blackwasp.co.uk/FileSystemWatcher.aspx
theLizardRank #1,079 · 1.8K reputationPosted Sep 16, 2012, 2:29 AM EDT
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.
VulpesRank #55 · 29.2K reputationPosted Sep 16, 2012, 6:51 AM EDT
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?