Get Folder Desire

i have folder abc/abcd/137383akkeiei. I want to get abc/abcd, how should I do it?
hope you will help me. Thanks

@HarryKan
image

.*(?=\/\d+)

System.Text.RegularExpressions.Regex.Match("abc/abcd/137383akkeiei",".*(?=\/\d+)").Value

Hi @HarryKan

Try this syntax


Input = "abc/abcd/137383akkeiei"

parentDirectory = Path.GetDirectoryName(Input)


Or else you can use the below also :

Input = "abc/abcd/137383akkeiei"

String.Join("/", Input.Split("/").Take(Input.Split("/").Length - 1))

Hope it helps!!

Hie @HarryKan for this use split condition i"m attaching screenshot how you can achieve this