private void StartScanForms(DoWorkEventArgs e) { if (String.IsNullOrWhiteSpace(Folder)) { return; } Scan scan = new Scan { FilePath = Folder, HashAlgorithm = Algorithm, Time = DateTime.Now }; try { scan.Insert(); } catch (Exception ex) { } List <string> allFiles = DirectoryParser.GetAllFiles(Folder, Recursive); int nFiles = allFiles.Count; int i = 0; foreach (string file in allFiles) { if (backgroundWorker1.CancellationPending) { e.Cancel = true; break; } else { try { FileScan.ScanFile(file, scan); int progress = (int)Math.Ceiling((double)i / nFiles) * 100; backgroundWorker1.ReportProgress(progress, (object)file); i++; } catch (Exception ex) { continue; } } } }
} // public void Setup /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++ * Method: public void BeginScan() * Summary: * Args: * Modifies: * Returns: * M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ public void BeginScan() { DirectoryInfo dir; FileScan file; String FullName; long FileSize; DateTime CreationDate; // Setup DirectoryInfo and FileScan instances; dir = new DirectoryInfo(StartDir); file = new FileScan(); /*--------------------------------------------------------- * To Do: Need to set this up to call some type of * callback fcn using whatever mecanisim C# * supports. * * For now, I just call an instance of FileScan * ----------------------------------------------------------*/ try { foreach (FileInfo f in dir.GetFiles(FileFilter)) { FullName = f.FullName; FileSize = f.Length; CreationDate = f.CreationTime; //Console.WriteLine("{0}", FullName); file.Setup(FullName, OutputFile, SearchString); if (0 == file.ScanFile()) { Console.WriteLine("DirScan:BeginScan() - ERROR - file.ScanFile Failed. Exiting\n"); return; } } } catch (System.IO.IOException) { Console.WriteLine("Caught System.IO.IOException while scanning {0}", FileFilter); } } // public void BeginScan