Home All Groups Group Topic Archive Search About

deleting files greater than x days

Author
25 Jan 2006 7:25 AM
James
i m looking for suggestions in this news groups what is the best way to
delete files greater than x days.

scenario / conditions

a) d:\dir\queue\*.* files to be deleted.
b) no-touch solutions  : use filewatcher on the above directory ?
c) the program will run locally on each machine ..or shld i run poll threads
(control by single machine to check other machines, so exe program only
reside on one system ?)

how shld i "poll" in such a way that in the above directory, it will
auto-delete files greater than 7 days ?

i m open to ideas ...

Author
25 Jan 2006 8:42 AM
Martin Widmer
Hi James

Write a system service or use the scheduler? The KISS solution would be a
batch file invoked via the scheduler.

Martin
Author
25 Jan 2006 11:48 AM
Herfried K. Wagner [MVP]
"James" <jkk***@hotmail.com> schrieb:
>i m looking for suggestions in this news groups what is the best way to
>delete files greater than x days.

In addition to the other replies:  You can use
'System.IO.File.GetLastWriteTime' to determine when the file has been
altered the last time.  Then you can subtract this date from 'Now' and check
the 'TotalDays' of the resulting 'TimeSpan' object.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>