Esempio n. 1
0
        public DirectoryPath FindChildDirectory(string pattern = "*",
                                                ActionOnNotFound actionOnNotFound = ActionOnNotFound.ReturnDefault)
        {
            var directories = FindChildDirectories(pattern);

            if (directories.Any())
            {
                return(directories.First());
            }

            switch (actionOnNotFound)
            {
            case ActionOnNotFound.ReturnDefault:
                return(default);

            case ActionOnNotFound.ThrowNewException:
                throw new DirectoryNotFoundException($"Can't find a child directory matching '{pattern}' in {RawPath}");

            default:
                throw new ArgumentOutOfRangeException(nameof(actionOnNotFound), actionOnNotFound, null);
            }
        }
Esempio n. 2
0
        public FilePath FindSiblingFile(string pattern = "*",
                                        ActionOnNotFound actionOnNotFound = ActionOnNotFound.ReturnDefault)
        {
            var files = FindSiblingFiles(pattern);

            if (files.Any())
            {
                return(files.First());
            }

            switch (actionOnNotFound)
            {
            case ActionOnNotFound.ReturnDefault:
                return(default);

            case ActionOnNotFound.ThrowNewException:
                throw new FileNotFoundException($"Can't find a sibling file matching '{pattern}' in {RawPath}");

            default:
                throw new ArgumentOutOfRangeException(nameof(actionOnNotFound), actionOnNotFound, null);
            }
        }