title: File.GetCreationTime throws The process cannot access the file because it is being used by another process
body: <p>I am using <code>File.GetCreationTime</code> to sort few files. After using this function when I am trying to move using <code>File.Move</code>  I get an error:</p>
  
  <pre><code>The process cannot access the file because it is being used by another process.
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>            foreach (var f in Directory.GetFiles(source))
              {
                  DateTime creation = File.GetCreationTime(f);
                  var fileDest = Path.Combine(destination, creation.Year.ToString());
                  if (!Directory.Exists(fileDest))
                  {
                      Directory.CreateDirectory(fileDest);
                  }
  
                  File.Move(f, Path.Combine(fileDest, Path.GetFileName(f)));
              }
  </code></pre>
  
  <p>Does <code>File.GetCreationTime</code> gets the filehandle?
  What am I doing wrong?</p>
  
  <p>I have used the <strong>retry pattern</strong> suggested but still the code fails:</p>
  
  <pre><code>            foreach (var f in Directory.GetFiles(source))
              {
                  DateTime creation = File.GetCreationTime(f);
                  var fileDest = Path.Combine(destination, creation.Year.ToString());
                  if (!Directory.Exists(fileDest))
                  {
                      Directory.CreateDirectory(fileDest);
                  }
  
                  for (int i = 1; i &lt;= 3; ++i)
                  {
                      try
                      {
                          File.Move(f, Path.Combine(fileDest, Path.GetFileName(f)));
                          break;
                      }
                      catch (IOException e)
                      {
                          if (i == 3)
                              throw;
  
                          Thread.Sleep(1000);
                      }
                  }
              }
  </code></pre>