My setup at home includes the Logitech Alert line of cameras. I like these cameras as they have on-board recording to a memory card and a PC based application that replicates those recordings to the PC hard drive. I needed a solution that would go out and look for the latest video clips when a scene was triggered and move them to an alternate location. In my case I moved them to a folder that will automatically synchronize with a cloud storage solution (allowing me to access them on a mobile device).

______________________

using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using MLS.ZWave.Service.Rules;
using MLS.ZWave.BusinessObjects;

public class CopyRecentVideos : ScriptBase, ScriptInterface {

public void runScript() {
try {
string searchFolder = @"e:\VideoFiles\";
string destinationFolder = @"e:\Latest_Videos\";
string filePattern = @"*.mp4";
int fileCount = 3;
int tmp = 1;
DirectoryInfo info = new DirectoryInfo(searchFolder);
FileInfo[] files = info.GetFiles(filePattern, System.IO.SearchOption.AllDirectories);
Array.Sort(files, delegate(FileSystemInfo a, FileSystemInfo b)
{
return b.LastWriteTime.CompareTo(a.LastWriteTime);
});
foreach (FileInfo file in files)
{
if (tmp <= filecount)="" file.copyto(destinationfolder="" +="" file.name,="" true);="">
tmp = tmp + 1;
}
} catch (Exception ex) {
var message = ex.Message;
writeLog(message);
}
}
}