void AppCollector.collect() { items = new List<Item>(); string[] pathargs; string pathExt; foreach (string anyFolder in anyFolders) { try { pathargs = anyFolder.Split(new char[]{';'}, 2); if (pathargs.Length < 2 || String.IsNullOrEmpty(pathargs[1])) { pathExt = null; } else { pathExt = pathargs[1]; } FileCollector fc = new FileCollector(pathargs[0], true, pathExt); fc.collect(); items.AddRange(fc.getItemList()); } catch (System.IO.IOException ioe) { Trace.WriteLine("Any Folder not exists: " + anyFolder + ", " + ioe.Message); } } }
public void getItemListTest() { FileCollector fc; List<Item> items, items2; fc = new FileCollector(@"c:\windows"); fc.collect(); items = fc.getItemList(); fc = new FileCollector(@"c:\windows", true, ".com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc"); fc.collect(); items2 = fc.getItemList(); if (items.Count != items2.Count) { Assert.Fail("item count error"); } if (!checkFiles(items, "explorer.exe;rundll32.exe")) { Assert.Fail("Not found: explorer.exe;rundll32.exe"); } if (checkFiles(items, "hogehoge.exe")) { Assert.Fail("Found error: hogehoge.exe"); } fc = new FileCollector(@"c:\windows", false, ".exe;.lnk;.zzz"); fc.collect(); items = fc.getItemList(); if (!checkFiles(items, "explorer.exe")) { Assert.Fail("Not found: explorer.exe"); } if (checkFiles(items, "rundll32.exe")) { Assert.Fail("Found error: rundll32.exe"); } fc = new FileCollector(@"c:\windows", true, "hogehoge"); fc.collect(); items = fc.getItemList(); if (items.Count() > 0) { Assert.Fail("Found error: hogehoge"); } }
public void collect() { items = new List<Item>(); foreach (String pathFolder in pathFolders) { try { FileCollector fc = new FileCollector(pathFolder, false, null); fc.collect(); items.AddRange(fc.getItemList()); } catch (IOException ioex) { Trace.WriteLine(pathFolder + ":" + ioex.Message); } } }