title: FileVersionInfo returns the wrong version when exe is changed
body: <p>I have a scenario where an application update may be installed by one user, while the application is running for another logged-in user.</p>
  
  <p>When the other user reconnects to their session, a call to <code>FileVersionInfo.GetVersionInfo(file)</code> is used to check if an update has occurred and is intended to restart the application.</p>
  
  <p>However, although the file in File Explorer displays the new version number (same version used for both file and product version), the call to <code>GetVersionInfo()</code> returns the current executing version - not the one on disk.</p>
  
  <p>I am setting only the <code>[assembly: AssemblyVersion("A.B.C.D")]</code> version attribute, and leaving the others undefined such that they default to the <code>AssemblyVersion</code> value.</p>
  
  <pre><code>string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName);
  /// or
  string file = @"C:\Program Files (x86)\Company\Product\product.exe";
  
  FileVersionInfo info = FileVersionInfo.GetVersionInfo(file);
  info.FileVersion; /// returns 1.0.0.0
  </code></pre>
  
  <p>However the File Version (and Product Version) details for <code>product.exe</code> in File Explorer indicate <code>2.0.0.0</code>.</p>
  
  <p>I think the executing assembly must be referencing some sort of virtualized file or a path in the <code>VirtualStore</code> because the file system has changed.</p>
  
  <p>How can I reliably get the actual File Version as it appears for <code>product.exe</code> in my <code>C:\Program Files (x86)\Company\Product</code> directory?</p>
  
  <hr>
  
  <p>To reproduce this, use the following <code>Console</code> application:</p>
  
  <pre><code>using System;
  using System.Diagnostics;
  using System.IO;
  
  namespace versiontest
  {
      class Program
      {
          static void Main(string[] args)
          {
              string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName);
              Console.WriteLine("Getting FileVersion of {0}: {1}", file, FileVersionInfo.GetVersionInfo(file).FileVersion);
  
              Console.WriteLine("Modify the file and press any key to continue...");
              Console.ReadKey();
  
              Console.WriteLine("Getting FileVersion of {0}: {1}", file, FileVersionInfo.GetVersionInfo(file).FileVersion);
  
              Console.WriteLine("Press any key to exit...");
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>Build two versions of the application.  The first should have the assembly version attribute, with no other version attributes, set in <code>AssemblyInfo.cs</code> as:</p>
  
  <pre><code>[assembly: AssemblyVersion("1.0.0.0")]
  </code></pre>
  
  <p>The second should have the version set as</p>
  
  <pre><code>[assembly: AssemblyVersion("2.0.0.0")]
  </code></pre>
  
  <p>Execute the version <code>1.0.0.0</code> <code>app.exe</code>, then after the first file version is retrieved, rename the executing <code>app.exe</code> to <code>app.exe.bak</code> and copy the version <code>2.0.0.0</code> <code>app.exe</code> into the same folder.</p>
  
  <p>When I do this, this is my console output:</p>
  
  <pre><code>Getting FileVersion of C:\Users\User\Documents\Company\Source\product\testapp\bin\x86\Debug\app.exe: 1.0.0.0
  Modify the file and press any key to continue...
  Getting FileVersion of C:\Users\User\Documents\Company\Source\product\testapp\bin\x86\Debug\app.exe: 1.0.0.0
  Press any key to exit...
  </code></pre>
  
  <p>If you run <code>app.exe</code> again immediately, being the version <code>2.0.0.0</code> application, the console output will show:</p>
  
  <pre><code>Getting FileVersion of C:\Users\User\Documents\Company\Source\product\testapp\bin\x86\Debug\app.exe: 2.0.0.0
  </code></pre>