Search code examples
c#.netcommand-linefile-uploadantivirus

Command Line Virus Scan with Output


What is the best tool to handle doing a command line virus scan in C#? I am looking to allow users to upload files to my site, but I want to scan their files for viruses and if one is found, to get the output of the result so I can suspend the user's account automatically.

Any tutorials, guides, or tools that are recommended for this?


Solution

  • I was able to accomplish this pretty easily using ClamWin with the following argument:

    C:\Program Files (x86)\ClamWin\bin\clamscan.exe -d C:\ProgramData\.clamwin\db --remove --stdout MY_FILE_NAME_AND_PATH
    

    This allows me to read the StOut from my C# code and parse it and it also removes the file if a virus exists.