【问题标题】:Scan uploaded files C# ASP.net扫描上传的文件 C# ASP.net
【发布时间】:2017-01-30 23:26:29
【问题描述】:
【问题讨论】:
标签:
c#
asp.net-mvc
antivirus
virus-scanning
【解决方案3】:
我将此库用于 .net(它使用 VirusTotal 公共 API):
https://github.com/Genbox/VirusTotal.NET
来自 github 的一个小例子:
static void Main(string[] args)
{
VirusTotal virusTotal = new VirusTotal("INSERT API KEY HERE");
//Use HTTPS instead of HTTP
virusTotal.UseTLS = true;
FileInfo fileInfo = new FileInfo("testfile.txt");
//Create a new file
File.WriteAllText(fileInfo.FullName, "This is a test file!");
//Check if the file has been scanned before.
Report fileReport = virusTotal.GetFileReport(fileInfo).First();
bool hasFileBeenScannedBefore = fileReport.ResponseCode == 1;
if (hasFileBeenScannedBefore)
{
Console.WriteLine(fileReport.ScanId);
}
else
{
ScanResult fileResults = virusTotal.ScanFile(fileInfo);
Console.WriteLine(fileResults.VerboseMsg);
}
}
一个完整的例子可以在这里找到:
https://github.com/Genbox/VirusTotal.NET/blob/master/VirusTotal.NET%20Client/Program.cs