title: C# How to grep the last word from a directory path?
body: <p>I have a program that "greps" out various directory paths from a log text file and prints various results according to the word. </p>
  
  <p>Examples of Directory paths:</p>
  
  <ul>
  <li><p>C:/Documents and Settings/All Users/Desktop/AccessData FTK Imager.lnk</p></li>
  <li><p>C:/Documents and Settings/All Users/Start Menu/Programs/AccessData</p></li>
  <li><p>C:/Documents and Settings/Administrator/Desktop/AccessData FTK Imager.exe:Zone.Identifier</p></li>
  </ul>
  
  <p>Therefore how can I grep out the file or folder name after the last "/"? This is to help the program to identify between files and folder. Please do take note of the multiple "." and white spaces found within a directory paths. etc "Imager.exe:Zone.Identifier". Therefore it is difficult to use <code>if(!name.contains()".")</code> </p>
  
  <p>Etc. How to get the "AccessData FTK Imager.lnk" or "AccessData" or "AccessData FTK Imager.exe:Zone.Identifier" from the path STRING?!</p>
  
  <p>May someone please advise on the methods or codes to solve this problem? Thanks!</p>
  
  <p>The codes:</p>
  
  <pre><code>if (!token[7].Contains("."))
                  {    
  
                      Console.WriteLine("The path is a folder?");
  
                      Console.WriteLine(token[7]);
  
                      Console.WriteLine(actions);
  
                      MacActions(actions);
  
                      x = 1;
                  } 
  </code></pre>