How do I open a folder using the filename directory?
<p>I have a <code>ListBox</code> which contains directories and file names which would be shown like this <code>C:\File.txt</code>. I would like to open the folder of the selected item using a <code>ContextMenuStrip</code> which would be like this</p>

<pre><code>If System.IO.File.Exists(ListBox1.SelectedItem) = True Then
    Process.Start(ListBox1.SelectedItem)
End If
</code></pre>

<p>but of course that only opens the file instead of the folder, how would I trim off the filename so it would only open the folder?</p>

<p>Note: <code>Process.Start("C:\")</code> wouldn't be a solution for me as there would be many different directories/files within this <code>ListBox</code>, so it wouldn't always be the same folder for all the listed files.</p>