Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check a file's 'Last Modified' date and copy it!

Status
Not open for further replies.

Kenny100

Technical User
Feb 6, 2001
72
NZ
Hi Folks

I have a foreach statment that copies files from one directory to another. How do I add in a statement that ensures the files are only copied across if their 'last modified' dates are different? The code looks like this:

string[] ListOfFiles = Directory.GetFiles(strSourceDirectory);
foreach(string fil in ListOfFiles)
{
// The files are copied across to the destination directory
File.Copy(fil, strDestinationDirectory + "\\" + Path.GetFileName(fil));
}

Cheers,
Kenny.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top