protected int FindFiles(List<FileName> files_to_process,
                              FilePath path,
                              string searchPattern,
                              bool clear,
                              System.IO.SearchOption so = System.IO.SearchOption.TopDirectoryOnly,
                              DateInterval interval = null)
        {
            try
             {
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path.Path);
            System.IO.FileInfo[] aryFi = di.GetFiles(searchPattern, so);

            if (clear)
               files_to_process.Clear();

            int found = 0;
            bool use;
            DateTime date;

            foreach (System.IO.FileInfo fi in aryFi)
            {
               use = true;

               if (interval != null)
               {
                  if (interval.UseStart)
                  {
                     date = DateTime.ParseExact(fi.Name.Substring(fi.Name.Length - 26, 10), "yyyyMMddHH", System.Globalization.CultureInfo.InvariantCulture);
                     if (date < interval.Start)
                        use = false;
                  }

                  if (interval.UseEnd)
                  {
                     date = DateTime.ParseExact(fi.Name.Substring(fi.Name.Length - 15, 10), "yyyyMMddHH", System.Globalization.CultureInfo.InvariantCulture);
                     if (date > interval.End)
                        use = false;
                  }
               }

               if (use)
               {
                  //Console.WriteLine("{0}", fi.FullName);
                  files_to_process.Add(new FileName(fi.FullName));
                  found++;
               }
            }

            last_exception = null;
            return found;
             }
             catch (Exception ex)
             {
            last_exception = ex;
            return -1;
             }
        }
        public bool Reset()
        {
            last_exception = null;

             tools_blocks = new Dictionary<string, ConfigNode>();
             tool_interpolate_info = null;
             tool_glue_info = null;

             replace_list = new Dictionary<string, string>();
             tool = new ExternalApp();
             tool_glue = new HDFGlue();

             interval = new DateInterval();

             return true;
        }
        protected List<FileName> CreateFileList(List<FilePath> folders_to_search, string search_pattern, DateInterval interval = null, bool search_sub_folders = true)
        {
            try
             {
            System.IO.SearchOption so;
            int found = 0;
            List<FileName> files_to_process = new List<FileName>();

            last_exception = null;

            if (search_sub_folders)
               so = System.IO.SearchOption.AllDirectories;
            else
               so = System.IO.SearchOption.TopDirectoryOnly;

            foreach (FilePath path in folders_to_search)
            {
               found += FindFiles(files_to_process, path, search_pattern, false, so, interval);
            }

            if (found < 0)
               return null;

            return files_to_process;
             }
             catch (Exception ex)
             {
            last_exception = ex;
            return null;
             }
        }