public static string GetRoot(string path) { if (String.IsNullOrEmpty(path)) return String.Empty; return path.Split(new[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries)[0]; }