I want to clarify the algorithm of work before writing a program.
There are two folders. If the second is not, then create. In the first folder are the files. If there are no files in the second one, copy the contents of the first one into it. Further, in real time, see the time for changing the files of the first folder. If in the first folder the contents are “fresher” than in the second, copy from the first to the second.
There is a code for txt files (see code below). How can I unload the entire directory from 1 folder and compare how I compared in the code. If there are tips, can you add the code? Any help will come down, I will be very grateful.
FileInfo q = new FileInfo(@"1\1.txt"); FileInfo w = new FileInfo(@"2\2.txt"); DateTimeOffset a = q.LastWriteTime; DateTimeOffset b = w.LastWriteTime; if (a < b) { w.Delete(); q.CopyTo(@"2\2.txt"); } if (q.Exists == false) { q.Delete(); w.CopyTo(@"1\1.txt"); }