If you’ve definitely got an absolute path, use Path.GetDirectoryName(path).
If you might only get a relative name, use new FileInfo(path).Directory.FullName.
Note that Path and FileInfo are both found in the namespace System.IO.
If you’ve definitely got an absolute path, use Path.GetDirectoryName(path).
If you might only get a relative name, use new FileInfo(path).Directory.FullName.
Note that Path and FileInfo are both found in the namespace System.IO.