我使用API编写了一个使用Virus Total扫描文件的函数。它工作得很好,但扫描结果没有按字母排序。
这是我的代码:
public void init(FileReport _scanResult) {
try {
if (_scanResult.ResponseCode == ReportResponseCode.Present) {
foreach (ScanEngine scan in _scanResult.Scans) {
if (scan.Detected == true) {
howMany++;
_scanResultItems.Add(new ScanResultItems {
AvName = scan.Name,
AvResult = new Uri("/Images/inWatch.avNOT.png", UriKind.RelativeOrAbsolute),
AvStatus = "BEDROHUNG!"
});
Width = 390;
}
else {
_scanResultItems.Add(new ScanResultItems {
AvName = scan.Name,
AvResult = new Uri("/Images/inWatch.avOK.png", UriKind.RelativeOrAbsolute),
AvStatus = "OK"
});
}
}
lstScanResults.ItemsSource = _scanResultItems.OrderBy(item => item.AvName).ToList();
}
}
catch(Exception ex) {
GeneralSettings.LogException(ex);
}
感谢您的回答!
答案 0 :(得分:0)
您可以使用System.Linq在结果集中订购商品; OrderBy()方法,如下所示:
_scanResultItems = _scanResultItems.OrderBy(item => item.Name).ToList();