If you always want the string part starting from the second last '/', then do this:
1.
Split[
^] the full filepath into an array by '/'
2. then simply concatenate the last two elements of this array.
see example:
using System;
public class Program
{
public static void Main()
{
string filepath="test/abc/pqr/test1/test2/abxc.txt";
string[] parts = filepath.Split('/');
int size = parts.Length;
string result = "/" + parts[size - 2] + "/" + parts[size - 1];
Console.WriteLine(result);
}
}
which give you:
/test2/abxc.txt