Question: I have a filepath say "C:\hello\hi\dotnet\abc.txt". I just want the directories from the path.

Expected Output :

```
hello
hi
dotnet

```

I have used `Path.DirectorySeparatorChar` but it doesn't work.So help me out to solve this problem.

Answer: 
How about using string.Split and ignore the first and last items in the array?
```
foreach (string s in System.IO.Path.GetDirectoryName (path).Split(System.IO.Path.DirectorySeparatorChar).Skip(1))
{
   //output
}

```