deleting files greater than x days

  • Thread starter Thread starter James
  • Start date Start date
J

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 ...
 
Hi James

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

Martin
 
James said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top