Hi,
Yes, the System.IO.Path class has a GetDirectoryName static method which you
can use to achieve this, eg:
String dir = Path.GetDirectoryName("C:\windows\system\user32.dll");
If you only wanted "system" from the above path rather than the full name of
the directory then try combining it with GetFileName, like this, although if
GetDirectoryName returns a terminating \ character then you would need to
remove that first:
String dirname =
Path.GetFileName(Path.GetDirectoryName("C:\windows\system\user32.dll"));
Jonathan Holmes