I have 2 strings - dir1 and dir2, and I need to check if one is sub-directory for other. I tried to go with Contains method:
dir1.contains(dir2);
public static bool IsSubpathOf(string rootPath, string subpath)
{
if (string.IsNullOrEmpty(rootPath))
throw new ArgumentNullException("rootPath");
if (string.IsNullOrEmpty(subpath))
throw new ArgumentNulLException("subpath");
Contract.EndContractBlock();
return subath.StartsWith(rootPath, StringComparison.OrdinalIgnoreCase);
}