We are writing a code to do on-demand scan of a file from C# using Windows Defender APIs.
[DllImport(@\"C:\\Program Files\\Windows Defender\\MpClient
You may use Antimalware Scan Interface to check file for malware.
The Antimalware Scan Interface (AMSI) is a generic interface standard that allows applications and services to integrate with any antimalware product present on a machine. It provides enhanced malware protection for users and their data, applications, and workloads.
It's available starting from Windows 10.