https://github.com/jitbit/windefender
Invoke Windows Defender scan from C# .NET Core
https://github.com/jitbit/windefender
antivirus dotnet windows-defender
Last synced: about 2 months ago
JSON representation
Invoke Windows Defender scan from C# .NET Core
- Host: GitHub
- URL: https://github.com/jitbit/windefender
- Owner: jitbit
- License: mit
- Created: 2022-06-09T09:15:29.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-25T08:19:15.000Z (over 2 years ago)
- Last Synced: 2025-12-17T18:34:38.365Z (4 months ago)
- Topics: antivirus, dotnet, windows-defender
- Language: C#
- Homepage:
- Size: 14.6 KB
- Stars: 19
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WinDefender - Windows Defender C# API
Invokes Windows Defender scan from C# .NET Core 6 (on Windows). Works even in ASP.NET
## Usage
Add [this file](/WinDefender.cs) to your project then call:
```csharp
//check by filename
bool isVirus = await WinDefender.IsVirus(@"c:\path\to\file");
//check by byte array
byte[] fileContents = ReadFileFromSomewhere();
bool isVirus = await WinDefender.IsVirus(fileContents);
//cancellation token support if you want ot abort
bool isVirus = await WinDefender.IsVirus(fileContents, cancellationToken);
```
## Background
Windows defender comes with a CLI tool. It does not launch the actual antivirus process, it's just a CLI-API to the antivirus that is always running. Even if you have "real time protection" disabled (recommended for server environment) the CLI still works.