title: Better way to check if a Path is a File or a Directory?
body: <p>I am processing a <code>TreeView</code> of directories and files. A user can select either a file or a directory and then do something with it. This requires me to have a method which performs different actions based on the user's selection.</p>
  
  <p>At the moment I am doing something like this to determine whether the path is a file or a directory:</p>
  
  <pre><code>bool bIsFile = false;
  bool bIsDirectory = false;
  
  try
  {
      string[] subfolders = Directory.GetDirectories(strFilePath);
  
      bIsDirectory = true;
      bIsFile = false;
  }
  catch(System.IO.IOException)
  {
      bIsFolder = false;
      bIsFile = true;
  }
  </code></pre>
  
  <p>I cannot help to feel that there is a better way to do this! I was hoping to find a standard .NET method to handle this, but I haven't been able to do so. Does such a method exist, and if not, what is the most straightforward means to determine whether a path is a file or directory?</p>