title: C# - How to extract the file name and extension from a path?
body: <p>So, say I have</p>
  
  <pre><code>string path = "C:\\Program Files\\Program\\File.exe";
  </code></pre>
  
  <p>How do I get only "File.exe"? I was thinking something with split (see below), but what I tried doesn't work...</p>
  
  <p>This is my code.</p>
  
  <pre><code>        List&lt;string&gt; procs = new List&lt;string&gt;(); //Used to check if designated process is already running
          foreach (Process prcs in Process.GetProcesses())
              procs.Add(prcs.ProcessName); //Add each process to the list
          foreach (string l in File.ReadAllLines("MultiStart.txt")) //Get list of processes (full path)
              if (!l.StartsWith("//")) //Check if it's commented out
                  if (!procs.Contains(l.Split('\\')[l.Split('\\').Length - 1])) //Check if process is already running
                      Process.Start(l);
  </code></pre>
  
  <p>I'm probably just being a noob. ._.</p>