public static void GetFileList()

in traceabilitytool/filefinder.cs [18:81]


        public static void GetFileList(string rootDirPath, string[] exceptions, ref List<string>FileList)
        {
            System.IO.FileInfo[] files = null;
            System.IO.DirectoryInfo[] subDirs = null;
            System.IO.DirectoryInfo rootDir = new DirectoryInfo(rootDirPath);

            // Return if no file filter pattern has been defined.
            if (filterPatternList.Count == 0)
                return;

            // First, process all the files directly under this folder for each file type
            foreach (string fileFilterPattern in filterPatternList)
            {
                try
                {
                    files = rootDir.GetFiles(fileFilterPattern);
                }
                catch (Exception exception)
                {
                    string message = "An error occurred while attempting to access a files with pattern " + fileFilterPattern + System.Environment.NewLine +
                                     "The error is:  " + exception.Message + System.Environment.NewLine;
                    if(ReportGenerator.useGUI)
                        MessageBox.Show(message, "Error");
                    else
                        Console.WriteLine(message);
                    Program.exitCode = 1;
                }

                if (files != null)
                {
                    // Process all the files in the current directory
                    foreach (System.IO.FileInfo fi in files)
                    {
                        FileList.Add(fi.FullName);
                    }
                }
            }

            // Now find all the subdirectories under this directory.
            try
            {
                subDirs = rootDir.GetDirectories();

                foreach (System.IO.DirectoryInfo dirInfo in subDirs)
                {
                    if ((exceptions== null) || !(exceptions.Any(s => s.Equals(dirInfo.FullName))))
                    {
                        // Resursive call for each subdirectory.
                        GetFileList(dirInfo.FullName, exceptions, ref FileList);
                    }
                }
            }
            catch (Exception exception)
            {
                string message = "An error occurred while attempting to access the folder " + rootDir + System.Environment.NewLine +
                                 "The error is:  " + exception.Message + System.Environment.NewLine;
                if (ReportGenerator.useGUI)
                    MessageBox.Show(message, "Error");
                else
                    Console.WriteLine(message);
                Program.exitCode = 1;
            }
           
        }