private void Form1_Load(object sender, EventArgs e) { try { AppDomain.CurrentDomain.AssemblyResolve += onResolve; AppDomain.CurrentDomain.AssemblyLoad += onLoad; trySetIcon(); String dir = Assembly.GetExecutingAssembly().Location; StringDict dirs = new StringDict(); dir = IOUtils.FindDirectoryToRoot(Path.GetDirectoryName(dir), "ImportDirs"); if (dir != null) { dirs.Add(dir, null); } StringDict files = new StringDict(); foreach (var f in History.LoadHistory(HISTORY_KEY)) { files[f] = null; dir = Path.GetDirectoryName(Path.GetDirectoryName(f)); if (!String.IsNullOrEmpty(dir)) { dirs[dir] = null; } } foreach (var kvp in dirs) { FileTree tree = new FileTree(); tree.AddFileFilter(@"\\import\.xml$", true); tree.ReadFiles(kvp.Key); if (tree.Files.Count != 0) { tree.Files.Sort(); foreach (var relfile in tree.Files) { files[tree.GetFullName(relfile)] = null; } } } ac = new DirectoryAutocompleter(comboBox1, files.Select(kvp => kvp.Key).ToList()); if (comboBox1.Items.Count > 0) { comboBox1.SelectedIndex = 0; } } catch (Exception ex) { Logs.ErrorLog.Log(ex); throw; } }
List <_FileElt> getFiles(PipelineContext ctx) { var list = new List <_FileElt>(); if (tree != null) { tree.MinUtcDate = getMinDate(ctx); tree.UserTag = list; //We fill list instead of tree.Files... tree.ReadFiles(Root, recursive ? _ReadFileFlags.rfSubdirs : 0); if (ExportDirs) { foreach (var d in tree.Dirs) { if (String.IsNullOrEmpty(d)) { continue; } String full = tree.GetFullName(d); var fsi = new DirectoryInfo(full); list.Add(new _FileElt(fsi)); } } if (ctx != null) { ctx.ImportLog.Log("-- Found {0} files.", list.Count); } goto EXIT_RTN; } if (File.IndexOf('*') < 0 && File.IndexOf('?') < 0) { list.Add(new _FileElt(File)); goto EXIT_RTN; } String dir = Path.GetDirectoryName(File); var dirInfo = new DirectoryInfo(dir); var files = dirInfo.GetFileSystemInfos(Path.GetFileName(File), this.recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); DateTime minUtc = getMinDate(ctx); DateTime maxUtc = DateTime.MaxValue; foreach (var info in files) { var dtLastWrite = info.LastWriteTimeUtc; if (info.CreationTimeUtc > dtLastWrite) { dtLastWrite = info.CreationTimeUtc; //In this case the file was probably moved... } if (dtLastWrite < minUtc) { continue; } if (dtLastWrite >= maxUtc) { continue; } list.Add(new _FileElt(info)); } EXIT_RTN: //Sort the list if requested and return the sorted list if (list.Count > 1) { Comparison <_FileElt> cmp = GetSorter(); if (cmp != null) { list.Sort(cmp); } } return(list); }