I think it would be overkill to have a Windows Service running 24hrs a day
taking up resources just to delete old files periodically. You would be
better served with a Console EXE that does the same thing and goes away when
it is done. You would simply have this run once a week (or whatever) under
Task Scheduler.
It should be easy to find recursive directory traversal code that will
delete all files (with whatever extension(s) ) that have a lastmodifieddate
of a certain value or older.
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com
"Matt" wrote:
> I have several folders on a server that contains files that go back 3-4 years. It was mentioned that keeping files that long is no longer needed. So my question is, is there a way to create a windows service in C# that can delete files in the folders that are older then 12 months?
>
> The server is structured something like this:
>
> DataLogs
> Server1
> App1 - this folder contains all the log files
>
> or it can look something like this:
> DataLogs
> Server1
> App1
> Logs - the log files can be stored here
>
>
> and another example:
> DataLogs
> App1 - logs stored here.
>
>
> So is there a way to do a 'high level' search and delete all files that are older then 12 months or do I have to go through every folder and look? How would that be accomplished?
>