a windows service to delete files

  • Thread starter Thread starter Keith Henderson
  • Start date Start date
K

Keith Henderson

It seems that I will soon have to write a windows service (or if there's
something more appripriate?) that will delete files off of a hard drive.

Here's an example, a file will be placed in a directory, at the time it is
placed there, a row will be inserted into an RDBMS table which gives the
filename, the location (could be on various servers), its time-to-live (like
2 days) and the datetime it was placed there, and probably a flag indicating
that it was deleted or not (like 0 or 1). Then I assume my application or
service will query the table periodically and if any files that have not
been deleted and their time is up, then it will delete them.

any comments on how I should do this?
 
Hi Keith,

You could use the FileSystemWatcher class of .NET for this. Something like:
- you set the filesyswatcher to 'watch' the folder in question.
- when a file is copied into that folder, an event will be fired which you
could handle. Within that, you could easily call the DB and insert a row.


HTH,
- Rakesh Rajan
 
Back
Top