title: How to get the name of File in a directory in C#
body: <pre><code>Directory.GetFiles(targetDirectory);
  </code></pre>
  
  <p>Using the above code we get the names(<strong>i.e full path)</strong> of all the files in the directory. but i need to get only the name of the file and not the path. So how can I get the name of the files alone excluding the path? Or do I need to do the string operations in removing the unwanted part?</p>
  
  <p>EDIT:</p>
  
  <pre><code>TreeNode mNode = new TreeNode(ofd.FileName, 2, 2);
  </code></pre>
  
  <p>Here <code>ofd</code> is a <code>OpenFileDialog</code> and <code>ofd.FileName</code> is giving the the filename along with it's Path but I need the file name alone.</p>