public static string GetDirectoryNameRootOk(string path) { // System.IO.Path.GetDirectoryName ("/") returns null. // Handle it specially. if (path == "/") return path; return System.IO.Path.GetDirectoryName (path); }