title: how to remove last part of string in c#
body: <p>I was trying to remove last part of a string but failed.Here string named <code>D:\software\VS2012\newtext.txt</code> and i want to trim last section of string so here <code>newtext.txt</code> . I should get <code>D:\software\VS2012</code> but how to do it in c#.When i tried it is removing all the string that has '\'. Here is  what i did in c#</p>
  
  <pre><code>string str = @"D:\softwares\VS2012\newtext.txt";
             str= str.Remove(str.IndexOf('\\'));
              Console.WriteLine(str);
  </code></pre>