private static bool SameRoot(string root, string path) { if (root.Length < 2 || path.Length < 2) { return(false); } if (!Path.IsDsc(root[0]) || !Path.IsDsc(root[1])) { return(root[0].Equals(path[0]) && path[1] == Path.VolumeSeparatorChar && (root.Length <= 2 || path.Length <= 2 || (Path.IsDsc(root[2]) && Path.IsDsc(path[2])))); } if (!Path.IsDsc(path[0]) || !Path.IsDsc(path[1])) { return(false); } string serverAndShare = Path.GetServerAndShare(root); string serverAndShare2 = Path.GetServerAndShare(path); return(string.Compare(serverAndShare, serverAndShare2, true, CultureInfo.InvariantCulture) == 0); }