예제 #1
0
        private static List <string> RecursiveDir(string[] sourceDir, string cond)
        {
            List <string> matchFiles = new List <string>();

            foreach (var dir in sourceDir)
            {
                string[] files = Directory.GetFiles(dir);
                foreach (string file in files)
                {
                    FileInfo f    = new FileInfo(file);
                    bool     flag = false;
                    switch (f.Extension.ToLower())
                    {
                    case ".docx":
                        flag = OpenXMLWord.SearchWordContains(file, cond);
                        if (flag)
                        {
                            matchFiles.Add(file);
                        }
                        break;
                    }
                    DirectoryInfo sdir          = new DirectoryInfo(dir);
                    string[]      directories   = Directory.GetDirectories(dir);
                    List <string> revMatchFiles = RecursiveDir(directories, cond);
                    matchFiles.AddRange(revMatchFiles);
                }
            }
            return(matchFiles);
        }
예제 #2
0
        public static List <string> ParseDirectoryFileContent(string dir, string condition)
        {
            List <string> matchFiles = new List <string>();

            string[] files = Directory.GetFiles(dir);
            foreach (string file in files)
            {
                FileInfo f    = new FileInfo(file);
                bool     flag = false;
                switch (f.Extension.ToLower())
                {
                case ".docx":
                    flag = OpenXMLWord.SearchWordContains(file, condition);
                    if (flag)
                    {
                        matchFiles.Add(file);
                    }
                    break;
                }
                //DirectoryInfo sdir = new DirectoryInfo(dir);
                //string[] directories = Directory.GetDirectories(dir);
                //List<string> revMatchFiles = RecursiveDir(directories, condition);
                //matchFiles.AddRange(revMatchFiles);
            }
            return(matchFiles);
        }