/// <summary> /// /// </summary> /// <param name="strFile"></param> public FileToScan(string strFile, Scanner scanEngine, string strTerm, Boolean bCase, Boolean bRegex) { this.strAPIs = scanEngine.strAPIs; this.strFile = strFile; this.frmMaster = scanEngine.frmMaster; this.engineLocal = scanEngine; }
private void scanToolStripMenuItem_Click(object sender, EventArgs e) { if (bScanRunning == true) { this.Invalidate(); lblStatus.Text = "Stopping.."; myScanner.Stop(); } else { if(profileLines == null){ MessageBox.Show("Please load a code profile","Code profile not loaded",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); return; } FolderBrowserDialog fbdDir = new FolderBrowserDialog(); fbdDir.Description = "Please select the directory to scan"; if (Properties.Settings.Default.LastPathSelected != null) { fbdDir.SelectedPath = Properties.Settings.Default.LastPathSelected; } if (fbdDir.ShowDialog() == DialogResult.Cancel) return; if (Directory.Exists(fbdDir.SelectedPath)) { int intTotalFiles = 0; lblStatus.Text = "Counting files..."; lblStatus.Invalidate(); string[] strFilesNoo = null; if (Properties.Settings.Default.ExtensionsLimit == true) { foreach(string strExt in Properties.Settings.Default.Extensions){ strFilesNoo = Directory.GetFiles(fbdDir.SelectedPath, strExt , SearchOption.AllDirectories); intTotalFiles += strFilesNoo.Count(); } } else { strFilesNoo = Directory.GetFiles(fbdDir.SelectedPath, "*.*", SearchOption.AllDirectories); intTotalFiles += strFilesNoo.Count(); } prgMain.Maximum = intTotalFiles; bScanRunning = true; bScanStopped = false; myScanner = new Scanner(); Properties.Settings.Default.LastPathSelected = fbdDir.SelectedPath; Properties.Settings.Default.Save(); if(Properties.Settings.Default.ExtensionsLimit == true){ string[] strExts = null; strExts = new string[Properties.Settings.Default.Extensions.Count]; Properties.Settings.Default.Extensions.CopyTo(strExts, 0); myScanner.Start(profileLines, fbdDir.SelectedPath, strExts , this); } else { string[] strAllExt = new string[]{"*.*"}; myScanner.Start(profileLines, fbdDir.SelectedPath, strAllExt, this); } scanToolStripMenuItem.Text = "&Stop\nScan"; lblStatus.Text = "Scanning..."; lblStatus.Invalidate(); this.listResults.ListViewItemSorter = null; //listResults.Enabled = false; //listResults.Visible = false; //this.mnuMain.Enabled = false;4 } else { MessageBox.Show("Directory " + fbdDir.SelectedPath + " does not exist", "Directory does not exist", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } }