Пример #1
0
        public FileInformationCollection GetFiles(string directory)
        {
            FileInfo[] files = new DirectoryInfo(directory).GetFiles();

            FileInformationCollection answer = new FileInformationCollection();

            foreach (FileInfo file in files)
            {
                answer.Add(new FileInformation(file));
            }

            return answer;
        }
Пример #2
0
        public FileInformationCollection GetFiles(string directory, string pattern)
        {
            MockFile mockDirectory = GetFilePath(directory).Last;

            if (!mockDirectory.IsDirectory)
            {
                return null;
            }

            string firstPart = pattern;
            string lastPart = pattern;

            int starIndex = pattern.IndexOf("*");

            if (starIndex != -1)
            {
                firstPart = pattern.Substring(0, starIndex);
                lastPart = pattern.Substring(starIndex + 1, pattern.Length - starIndex - 1);
            }

            FileInformationCollection files = new FileInformationCollection();
            foreach (MockFile child in mockDirectory.Children)
            {
                if (child.Name.StartsWith(firstPart) && child.Name.EndsWith(lastPart))
                {
                    MockFileInformation info = new MockFileInformation(child, directory);
                    files.Add(info);
                }
            }

            return files;
        }
Пример #3
0
        private static FileInformationCollection FileInfoArrayToCollection(FileInfo[] files)
        {
            FileInformationCollection answer = new FileInformationCollection();

            foreach (FileInfo file in files)
            {
                answer.Add(new FileInformation(file));
            }

            return answer;
        }