title: Force close an open network file on Windows Server 2012 with C#
body: <p>Is there any way to force closed any instance of a specific file on Server 2012?</p>
  
  <p>For arguments sake, call the link to the file <code>D:\Shares\Shared\Sharedfile.exe</code></p>
  
  <p>I have C# code which copies the latest version of a program into this directory, which often has people using the program during the day. Closing open file handles and replacing the file has worked well, because it just means next time the user opens the program they have all the latest changes.</p>
  
  <p>However it gets a little monotonous doing this from computer management on the server, so I was wondering if there was a way to do it from C# code?</p>
  
  <p>I tried this but it doesn't have the right overloads that I need. Perhaps is there something in the <code>File</code> class I could use?</p>
  
  <p><strong>EDIT</strong> The C# code to close the file will <em>NOT</em> be running on the host server.</p>
  
  <pre><code>[DllImport("Netapi32.dll", SetLastError=true, CharSet = CharSet.Unicode)]
  public static extern int NetFileClose(string servername, int id);
  </code></pre>