Ocronet.Dynamic.Utils.DirPattern.DirPattern C# (CSharp) 메소드

DirPattern() 공개 메소드

Scan directory for regex pattern. You can use brackets () to saved substring.
public DirPattern ( string DirName, string EntryPattern ) : System
DirName string
EntryPattern string
리턴 System
        public DirPattern(string DirName, string EntryPattern)
        {
            this.dirName = DirName;
            this.entryPattern = EntryPattern;
            Regex regex = new Regex(entryPattern + "$", RegexOptions.Compiled);
            dirFiles = new List<string>();
            string[] entries = {};
            try
            {
                entries = Directory.GetFileSystemEntries(dirName);
            }
            catch (DirectoryNotFoundException) { }
            foreach (string entry in entries)
            {
                string fileName = Path.GetFileName(entry);
                Match match = regex.Match(entry);
                if (match.Success && fileName == match.Value)
                    dirFiles.Add(match.Groups[match.Groups.Count - 1].Value);
            }
        }