public static bool Exist(string DirName, string EntryPattern) { bool result = false; Regex regex = new Regex(EntryPattern + "$"); 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) { result = true; break; } } return result; }
public override void SetPrefix(string prefix) { if (DirPattern.Exist(prefix, @"[0-9][0-9][0-9][0-9]", @"([0-9][0-9][0-9][0-9])\.png")) { Global.Debugf("info", "selecting OldBookStore"); p = new OldBookStore(); } else { Global.Debugf("info", "selecting (new) BookStore"); p = new BookStore(); } p.SetPrefix(prefix); }