title: File.Move issue: Process cannot access the file exception
body: <p>I am getting an error when I run this newFile method:</p>
  <pre><code>class logFile
  {
      public static string logpath = @&quot;D:\Program Files\CustomApps\DataFeed\&quot;;
  
      public static void log(string log)
      {
          string timestamp = DateTime.Now.ToString(&quot;yyyy_MM_ddTHH_mm_ss&quot;);
          Console.WriteLine(timestamp + log);
          File.AppendAllText(logpath + @&quot;log_file_current.txt&quot;, timestamp + log + Environment.NewLine);
      }
  
      public static void newFile()
      {
          if (File.Exists(logpath + @&quot;log_file_current.txt&quot;) == true)
          {
              File.Move(logpath + @&quot;log_file_current.txt&quot;
                      , logpath + @&quot;log_files\log_file_ORPHANED_&quot; + DateTime.Now.ToString(&quot;yyyy_MM_ddTHH_mm_ss&quot;) + &quot;.txt&quot;);
          }
  
          try
          {
              File.Create(logpath + @&quot;log_file_current.txt&quot;);
              logFile.log(&quot;logFile created.&quot;);
          }
          catch(System.NotSupportedException ex)
          {
              Console.WriteLine(ex.Message);
          }
      }
  }
  </code></pre>
  <p>I get the following error:</p>
  <p><a href="https://i.stack.imgur.com/G1yKB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G1yKB.png" alt="enter image description here" /></a></p>
  <p>If I comment the body of the &quot;newFile&quot; code out then it runs without error, but then I would need to manually archive.  If I comment out the <code>File.Move</code> part it all runs fine so this is the culprit.</p>
  <p>How can I release the file so that it can be moved?</p>