Ejemplo n.º 1
0
        private string FindPath(string path, Predicate <string> pathExists)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            if (RegexPatterns.SchemePrefixRegex.IsMatch(path))
            {
                // Web url can't be a folder
                return(null);
            }

            var currentDirFilePath = fileSystem.GetFullPath(path);

            if (pathExists(currentDirFilePath))
            {
                return(currentDirFilePath);
            }

            var executingPath = environment.GetExeuctingAssemblyPath();
            var executingDir  = fileSystem.GetDirectoryName(executingPath);
            var filePath      = fileSystem.GetFullPath(Path.Combine(executingDir, path));

            if (pathExists(filePath))
            {
                return(filePath);
            }

            return(null);
        }