We have some servers in England and in many other countries, everyday we take a database backup for each database we have and put it in a specific folder. Finally, all those backups are collected here in one of our servers. So, what I'm trying to do is a small application running as a script, all its job is to connect to our branches' servers and copy the lastest backup files in those specific backup folders to a folder in the server here. I hope I explained my idea well
Here's a simple method that will take the path to the source folder and the path to the destination folder and the target date, and will copy every file in the source folder that was created on or after the target date and copy it to the destination folder.
public void CopyBackups(string SourceFolder, string DestinationFolder, DateTime AfterDate)
List<FileInfo> FileList = new DirectoryInfo(SourceFolder).GetFiles().ToList();
'Change which files are selected here.
FileList = FileList.Where(x => x.CreationTime >= AfterDate).ToList();
foreach (FileInfo file in FileList)
file.CopyTo(DestinationFolder + @"\" + file.Name);