System.IO.Path.Path.SameRoot C# (CSharp) Méthode

SameRoot() static private méthode

static private SameRoot ( string root, string path ) : bool
root string
path string
Résultat bool
		static bool SameRoot (string root, string path)
		{
			// compare root - if enough details are available
			if ((root.Length < 2) || (path.Length < 2))
				return false;

			// UNC handling
			if (IsDsc (root[0]) && IsDsc (root[1])) {
				if (!(IsDsc (path[0]) && IsDsc (path[1])))
					return false;

				string rootShare = GetServerAndShare (root);
				string pathShare = GetServerAndShare (path);

				return String.Compare (rootShare, pathShare, true, CultureInfo.InvariantCulture) == 0;
			}
			
			// same volume/drive
			if (!root [0].Equals (path [0]))
				return false;
			// presence of the separator
			if (path[1] != Path.VolumeSeparatorChar)
				return false;
			if ((root.Length > 2) && (path.Length > 2)) {
				// but don't directory compare the directory separator
				return (IsDsc (root[2]) && IsDsc (path[2]));
			}
			return true;
		}