title: Catching IOException
body: <p>I am writing a C# application in which I have to display a message if File is already being used by some process and if the file doesnot exist, the application needs to display another message.</p>
  
  <p>Something like this:</p>
  
  <pre><code>try 
  {
      //Code to open a file
  }
  catch (Exception e)
  {
      if (e IS IOException)
      {
          //if File is being used by another process
          MessageBox.Show("Another user is already using this file.");
  
          //if File doesnot exist
          MessageBox.Show("Documents older than 90 days are not allowed.");
      }
  }
  </code></pre>
  
  <p>Since <code>IOException</code> covers both the conditions, how do I distinguish if this exception is caught because of File being used by another process or File doesnot exist?</p>
  
  <p>Any help would be highly appreciated.</p>