-1

I'm working on an application where I video record the screen of the script running. I use SharpAvi for recording the screen and I would like to set a time for deleting the file. The only way I found is to run a batch that looks for files older than 7 days or so. I would like to have to set the delete time upon creation. I'm not sure if there is a way to do that or even of Windows support this kind of file creation.

0x2bad
  • 308
  • 2
  • 11

1 Answers1

2

Rather than using a batch file, create a RemoveOldRecordings method in your application that is called when your application is started. Use the GetFiles to read your "recording" directory, deleting "recording" files with LastWriteTime more than 7 days ago.

If you allow the users to save the recordings to different locations, though, you should not automatically delete files without their confirmation.

Also, while testing, rather than delete files, just output the filenames you've identified for delete to log or console window until you're sure you're handling that correctly.

Gordon Bell
  • 13,337
  • 3
  • 45
  • 64
  • I don't let the user choose the save directory. I think your solution is the best I can do. Thanks! – 0x2bad Jun 19 '17 at 19:03