public ScanResult ScanStream(Stream stream)
        {
            EnsureDefaultKeyIsSet();

            var apiInstance = new ScanApi();
            var result      = new ScanResult();

            try
            {
                // ensure stream is ready for read
                stream.Position = 0;
                var r = apiInstance.ScanFileAdvanced(stream, false);

                if (r.CleanResult.HasValue)
                {
                    result.IsSafe = true;
                }
                else if (r.FoundViruses != null && r.FoundViruses.Count > 0)
                {
                    var viruses = new List <string>();
                    r.FoundViruses.ForEach(v => viruses.Add(v.VirusName));
                    result.Message = $"Virus found: {string.Join(",", viruses)}";
                }
            }
            catch (Exception e)
            {
                result.Message = $"Unable to complete scan, {e.Message}";
            }

            return(result);
        }
        private void btnScanForViruses_Click(object sender, RoutedEventArgs e)
        {
            var apiInstance = new ScanApi();

            apiInstance.Configuration.AddApiKey("Apikey", "YOUR_API_KEY");

            var inputFile         = new System.IO.FileStream(txtSource.Text, System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on.
            var allowExecutables  = false;                                                             // bool? | Set to false to block executable files (program code) from being allowed in the input file.  Default is false (recommended). (optional)
            var allowInvalidFiles = false;                                                             // bool? | Set to false to block invalid files, such as a PDF file that is not really a valid PDF file, or a Word Document that is not a valid Word Document.  Default is false (recommended). (optional)
            var allowScripts      = false;                                                             // bool? | Set to false to block script files, such as a PHP files, Pythong scripts, and other malicious content or security threats that can be embedded in the file.  Set to true to allow these file types.  Default is false (recommended). (optional)
            var restrictFileTypes = "";                                                                // string | Specify a restricted set of file formats to allow as clean as a comma-separated list of file formats, such as .pdf,.docx,.png would allow only PDF, PNG and Word document files.  All files must pass content verification against this list of file formats, if they do not, then the result will be returned as CleanResult=false.  Set restrictFileTypes parameter to null or empty string to disable; default is disabled. (optional)

            VirusScanAdvancedResult result = apiInstance.ScanFileAdvanced(inputFile, allowExecutables, allowInvalidFiles, allowScripts, restrictFileTypes);

            if (result.CleanResult.Value)
            {
                MessageBox.Show("File is clean.");
            }
            else
            {
                MessageBox.Show("File is virus infected or contains dangerous files such as executables!");
            }

            inputFile.Close();
        }