title: Releasing a media file in Windows Media Player Control
body: <p>In my C# code, I tried to delete a video file while I was playing it by Windows Media Player Control.</p>
  
  <p>I stopped playing, made its URL null, and even close the Media Player Control.</p>
  
  <pre><code>string delFile = axWindowsMediaPlayer1.Ctlcontrols.currentItem.sourceURL;
  
  axWindowsMediaPlayer1.Ctlcontrols.stop();
  axWindowsMediaPlayer1.URL = null;
  axWindowsMediaPlayer1.close();
  
  File.Delete(delFile);
  </code></pre>
  
  <p>However, I have faced 'System.UnauthorizedAccessException' because the file was in use.</p>
  
  <p>Is there any way to release the media file connected to my Windows Media Player Control?</p>