title: how can I copy a file with a certain date in c#
body: <p>I have an issue with my code I can get it to copy all the files in  a directory and it's subdirectories and I have got an if statement telling it to copy a file if the modified date is the same as today but it still copy's all the files I have searched on the internet for a solution and they all come up with vague answers that are similar to the doe I already have I have pasted the code below.</p>
  
  <pre><code>DirectoryInfo source = new DirectoryInfo(dlg.SelectedPath);
  DirectoryInfo target = new DirectoryInfo(dlg2.SelectedPath);
  
  DirectoryInfo dir = new DirectoryInfo(dlg.SelectedPath);
  FileInfo[] fis = dir.GetFiles("*", SearchOption.AllDirectories);
  foreach (FileInfo fi in fis)
  {
      if (fi.LastWriteTime.Date == DateTime.Today.Date)
      {
          FileInfo[] sourceFiles = source.GetFiles("*", SearchOption.AllDirectories);
          foreach (FileInfo fc in sourceFiles)
              if (fc.LastWriteTime.Date == DateTime.Today.Date)
                  for (int i = 0; i &lt; sourceFiles.Length; ++i)
                      File.Copy(sourceFiles[i].FullName, target.FullName + "\\" + sourceFiles[i].Name, true);
      }
  }
  </code></pre>
  
  <p>any help will be appreciated </p>