You could solve that using LINQ. Assuming your strings are stored in an IEnumerable or similar you could do the following:
var query = from element in stringCollection
select element.Substring(0, element.LastIndexOf('\\'));
foreach (var item in query)
{
}