Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, kindly help on creation of project on copying or moving files(with count) from 1 directory to another, I am having a Archive folder which has more than 7000 files, i have to move/copy (with count) the files based on Datetimepicker1 to Datetimepicker2, right now below is the code which i am using to move the files

C#
DirectoryInfo source = new DirectoryInfo(textbox1.Text);
DirectoryInfo destination = new DirectoryInfo(textbox2.Text);
foreach (FileInfo file in source.GetFiles("*." + txtExtensions.Text))
{
   file.MoveTo(Path.Combine(destination.FullName, file.Name));
}


waiting eagerly
Posted

1 solution

Change your code to the following :
C#
...
if(file.LastWriteTime > datetimepicker1.Value && file.LastWriteTime < datetimepicker2.value)
   file.MoveTo(...);
...
 
Share this answer
 
Comments
jaipe 16-Sep-11 9:45am    
Thankyou very much, exactly what i was looking for, kindly let me know same on file count to a textbox based on the datetimepicker1 to datetimepicker2
Mehdi Gholam 16-Sep-11 9:50am    
Just increment a counter in the if statement
jaipe 17-Sep-11 3:03am    
Pls guide me, i am confused

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