Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How Do I copy files with specific extensions saved in an array and also not older than 2 days

What I have tried:

string[] files = Directory.GetFiles(Server.MapPath("~/Folder1/"), "*.doc");
foreach(string file in files)
{
    File.Copy(file, Server.MapPath("~/Folder2/") + Path.GetFileName(file));
}
 
files = Directory.GetFiles(Server.MapPath("~/Folder1/"), "*.docx");
foreach (string file in files)
{
    File.Copy(file, Server.MapPath("~/Folder2/") + Path.GetFileName(file));
}
Posted
Comments
ZurdoDev 11-Jan-18 14:36pm    
It looks like you have code that is getting certain extensions so all you need to lookup now is how to determine the creation date.
Member 13618575 11-Jan-18 14:38pm    
Well id like to have a single list holding several extensions
ZurdoDev 11-Jan-18 14:40pm    
See the documentation then, https://msdn.microsoft.com/en-us/library/wz42302f(v=vs.110).aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900