Skip to content
Christian Haase edited this page Dec 1, 2025 · 1 revision

Maintaining good quality documentation is a priority for ByteGuard. If you find missing or inaccurate content, or if you'd like to extend the wiki with a topic or tutorial, please let us know via the issue tracker.

ByteGuard.FileValidator

ByteGuard.FileValidator is a lightweight security-focused library for validating user-supplied files in .NET applications.
It helps you enforce consistent file upload rules by checking:

  • Allowed file extensions
  • File size limits
  • File signatures (magic numbers) to detect spoofed types
  • Specification conformance for Office Open XML / Open Document Formats (.docx, .xlsx, .pptx, .odt)
  • Malware scan result using a varity of scanners (requires the addition of a specific ByteGuard.FileValidator scanner package)

⚠️ Important: This package is one layer in a defense-in-depth strategy.
It does not replace endpoint protection, sandboxing, input validation, or other security controls.

Features

  • ✅ Validate files by extension
  • ✅ Validate files by size
  • ✅ Validate files by signature (magic-numbers)
  • ✅ Validate files by specification conformance for archive-based formats (Open XML and Open Document Formats)
  • Ensure no malware through a variety of antimalware scanners
  • ✅ Validate using file path, Stream, or byte[]
  • ✅ Configure which file types to support
  • ✅ Configure whether to throw exceptions or simply return a boolean
  • Fluent configuration API for easy setup

Clone this wiki locally