title: C# equivalent to InStrRev
body: <p>I have been searching for over an hour and I can not for the life of me figure out how to search a string variable starting on the right. What I want to do is to get the last folder of a path (right before the file name), In VB6 I would do something like this:</p>
  
  <pre><code>Dim s As String
  
  s = "C:\Windows\System32\Foo\Bar\"
  
  Debug.Print Mid(s, InStrRev(Left(s, Len(s) - 1), "\") + 1)
  </code></pre>
  
  <p>Here is what I tried so far:</p>
  
  <pre><code>string s = "C:\\Windows\System32\\Foo\\Bar\\";
  
  s = agencyName.Substring(s.LastIndexOf("\\") + 1) 
  </code></pre>