the disk cleanup example might be dangerous!

Topics: Developer Forum
Aug 26, 2008 at 5:12 PM
correct me if I'm wrong but by using the LastWriteTime you might delete files that are still actively being used.  Using lastaccessedtime might be a better alternative.
tr
Coordinator
Aug 30, 2008 at 4:37 PM
Depends on what rules you want to follow to delete files. If you wanted to simply delete files that are no longer accessed, then using the last accessed date does make more sense.
This sample was pulled from a production environment on a web server to clean up temporary files created by various apps on the web server. For that purpose, last write time = create date and hence the criteria in the sample.
Of course, you should always review any scripts you download from the web and double check to make sure it does exactly what you expect it to do!!
 Either that or very good reliable backups :-)
Sep 2, 2008 at 3:37 PM
yep in hindsight I was a little harsh on the wording of the subject!  sorry about that.
tr