Skip to content

Periodically cleans up a folder.

Notifications You must be signed in to change notification settings

tallesl/net-Fresh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fresh

A .NET library that periodically cleans up a folder. Useful for cleaning up temporary files.

Usage

using FreshLibrary;

var cleaner = new FreshFolder("Temp", TimeSpan.FromMinutes(30), TimeSpan.FromHours(2), FileTimestamps.Creation);

This creates and starts a cleaner that, every 2 hours, deletes all files in Temp folder that have been created over 30 minutes ago. The cleaner already starts its cleaning after its construction.

Remember to Dispose() it when you're done. Consider disposing the cleaner on Application_End or ProcessExit.