Automatically delete logs older than X days?
Ask by ICSM Computer
Updated 29 May 2025
Absolutely — you can automatically delete log files older than a specified number of days (e.g., 30 days) to keep your disk clean and avoid storage bloat.
Here’s a clean implementation.
Step-by-Step: Auto-Delete Old Log Files
LogCleanerUtilityExample Usage
You can call this cleanup together with your ZIP logic or as a standalone scheduled task.
Example: Run on App Start (
Global.asax.cs)Optional Enhancements
Would you like to:
Archivefolder instead of deleting?.txt, not.zip?