private async Task ScanDirectory(string scanPath) { WriteLogLine("Scanning directory " + scanPath); var results = await _clamEngine.ScanDirectoryAsync(scanPath); var resultList = results.ToList(); var infectedList = resultList.Where(r => r.Infected).ToList(); WriteLogLine(scanPath + " scanned"); WriteLogLine(string.Format("{0} file(s) scanned, {1} infected", resultList.Count, infectedList.Count)); foreach (var infected in infectedList) { WriteLogLine(string.Format("{0} infected with {1}", infected.Path, infected.VirusName)); } WriteLogLine("=========="); }
/// <summary> /// Asynchronously scans a directory for viruses, recursing into subdirectories. /// </summary> /// <param name="engine">ClamAV engine instance.</param> /// <param name="path">Path to scan.</param> /// <param name="options">Scan options.</param> /// <returns>The task object representing the asynchronous operation. The Result property on the task returns the scan results.</returns> public static async Task <IEnumerable <FileScanResult> > ScanDirectoryAsync(this ClamEngine engine, string path, ScanOptions options) { return(await engine.ScanDirectoryAsync(path, options, true, 0)); }