Esempio n. 1
0
        }//end method

        public static IEnumerable <FileSystemInfo> RecurseFileSystem(string path,
                                                                     Predicate <FileSystemInfo> filter)
        {
            DirectoryStateMachine directories =
                new DirectoryStateMachine(new DirectoryInfo(path), filter);
            DirectoryInfo dirInfo = directories.GetNext();

            FileStateMachine files =
                new FileStateMachine(dirInfo, filter);
            FileInfo fileInfo = files.GetNext();

            //recurse the files
            while ((fileInfo = files.GetNext()) != null)
            {
                if (filter.Invoke(fileInfo))
                {
                    yield return(fileInfo);
                }
            }

            //recurse the directories
            while ((dirInfo = directories.GetNext()) != null)
            {
                if (filter.Invoke(dirInfo))
                {
                    yield return(dirInfo);
                }

                //the recursive part, is different for IEnumerables
                foreach (var subDir in RecurseFileSystem(path + "\\" + dirInfo.Name, filter))
                {
                    yield return(subDir);
                }
            }
        } //end method
Esempio n. 2
0
        }//end method

        //*** need for merge solutions program ***
        public static IEnumerable <string> RecurseFiles(string path)
        {
            DirectoryStateMachine directories =
                new DirectoryStateMachine(new DirectoryInfo(path));
            DirectoryInfo dirInfo;

            FileStateMachine files =
                new FileStateMachine(new DirectoryInfo(path));
            FileInfo fileInfo;

            //recurse the files
            while ((fileInfo = files.GetNext()) != null)
            {
                yield return(fileInfo.FullName);
            }

            //recurse the directories
            while ((dirInfo = directories.GetNext()) != null)
            {
                //yield return dirInfo;

                //the recursive part, is different for IEnumerables
                foreach (var subFile in RecurseFiles(path + "\\" + dirInfo.Name))
                {
                    yield return(subFile.ToString());
                }
            }
        }//end method
Esempio n. 3
0
        public static IEnumerable <FileSystemInfo> RecurseFiles(this DirectoryInfo dir)
        {
            DirectoryStateMachine directories =
                new DirectoryStateMachine(new DirectoryInfo(dir.FullName));
            DirectoryInfo dirInfo = directories.GetNext();

            FileStateMachine files =
                new FileStateMachine(dirInfo);
            FileInfo fileInfo = files.GetNext();

            //recurse the files
            while ((fileInfo = files.GetNext()) != null)
            {
                yield return(fileInfo);
            }

            //recurse the directories
            while ((dirInfo = directories.GetNext()) != null)
            {
                //yield return dirInfo;

                //the recursive part, is different for IEnumerables
                foreach (var subFile in new DirectoryInfo(dir.FullName + "\\" + dirInfo.Name).RecurseFiles())
                {
                    yield return(subFile);
                }
            }
        }//end method
Esempio n. 4
0
        public static IEnumerable<FileSystemInfo> RecurseFiles(this DirectoryInfo dir)
        {
            DirectoryStateMachine directories =
                new DirectoryStateMachine(new DirectoryInfo(dir.FullName));
            DirectoryInfo dirInfo = directories.GetNext();

            FileStateMachine files =
                new FileStateMachine(dirInfo);
            FileInfo fileInfo = files.GetNext();

            //recurse the files
            while (( fileInfo = files.GetNext() ) != null) {
                yield return fileInfo;
            }

            //recurse the directories
            while (( dirInfo = directories.GetNext() ) != null) {
                //yield return dirInfo;

                //the recursive part, is different for IEnumerables
                foreach (var subFile in new DirectoryInfo(dir.FullName + "\\" + dirInfo.Name).RecurseFiles())
                    yield return subFile;
            }
        }
Esempio n. 5
0
        public static IEnumerable<FileSystemInfo> RecurseFileSystem(string path, 
            Predicate<FileSystemInfo> filter)
        {
            DirectoryStateMachine directories =
                new DirectoryStateMachine(new DirectoryInfo(path), filter);
            DirectoryInfo dirInfo = directories.GetNext();

            FileStateMachine files =
                new FileStateMachine(dirInfo, filter);
            FileInfo fileInfo = files.GetNext();

            //recurse the files
            while (( fileInfo = files.GetNext() ) != null) {
                if (filter.Invoke(fileInfo))
                    yield return fileInfo;
            }

            //recurse the directories
            while (( dirInfo = directories.GetNext() ) != null) {
                if(filter.Invoke(dirInfo))
                    yield return dirInfo;

                //the recursive part, is different for IEnumerables
                foreach (var subDir in RecurseFileSystem(path + "\\" + dirInfo.Name, filter))
                    yield return subDir;
            }
        }
Esempio n. 6
0
        //*** need for merge solutions program ***
        public static IEnumerable<string> RecurseFiles(string path)
        {
            DirectoryStateMachine directories =
                new DirectoryStateMachine(new DirectoryInfo(path));
            DirectoryInfo dirInfo;

            FileStateMachine files =
                new FileStateMachine(new DirectoryInfo(path));
            FileInfo fileInfo;

            //recurse the files
            while (( fileInfo = files.GetNext() ) != null) {
                yield return fileInfo.FullName;
            }

            //recurse the directories
            while (( dirInfo = directories.GetNext() ) != null) {
                //yield return dirInfo;

                //the recursive part, is different for IEnumerables
                foreach (var subFile in RecurseFiles(path + "\\" + dirInfo.Name))
                    yield return subFile.ToString();
            }
        }