Zero-alloc, AOT-ready WinFsp binding for modern .NET — build user-mode file systems on Windows with native performance.
| WinFsp.Native | Official WinFsp.Net | |
|---|---|---|
| Native AOT | Full support (IsAotCompatible) |
Not compatible (reflection-based) |
| Target | .NET 8+ | .NET Standard 2.0 / .NET Framework 3.5 |
| Hot-path alloc | Zero managed heap allocation | Allocates per callback |
| P/Invoke | [LibraryImport] source generator |
[DllImport] with marshaling |
| Async I/O | ValueTask<T> + STATUS_PENDING |
Synchronous only |
| API style | IFileSystem interface + FileSystemHost |
Inheritance-based FileSystemBase |
| Dependencies | Zero NuGet dependencies | Microsoft.Win32.Registry + System.IO.FileSystem.AccessControl |
dotnet add package WinFsp.Nativeusing WinFsp.Native;
class MyFs : IFileSystem
{
public bool SynchronousIo => true;
public int GetVolumeInfo(out ulong totalSize, out ulong freeSize, out string volumeLabel)
{
totalSize = 1024 * 1024;
freeSize = 512 * 1024;
volumeLabel = "MyDrive";
return NtStatus.Success;
}
// Implement other IFileSystem methods...
}
// Mount
var host = new FileSystemHost(new MyFs());
host.Mount("Z:");Implement the IFileSystem interface with familiar .NET types (string, Memory<byte>, ValueTask<T>). The FileSystemHost handles all WinFsp plumbing — mounting, callback dispatch, async STATUS_PENDING, buffer management, and cancellation.
using WinFsp.Native;
// One using gets you everything: IFileSystem, FileSystemHost, NtStatus,
// FspFileInfo, CleanupFlags, CreateOptions, result types, etc.Direct function pointer access to all 64 WinFsp callback slots. Full control, zero abstraction overhead.
using WinFsp.Native;
using WinFsp.Native.Interop; // FspVolumeParams, FspFileSystemInterface, etc.
var fs = new WinFspFileSystem();
fs.VolumeParams.SectorSize = 4096;
fs.Interface.Read = &OnRead;
fs.Mount("Z:");- Windows 10/11
- WinFsp 2.x installed (with Developer files for building)
- .NET 8.0+ SDK
src/WinFsp.Native/ # The binding library
tests/WinFsp.Native.Tests/ # Integration tests (mounts real WinFsp FS)
examples/HelloFs/ # Minimal read-only file system example
dotnet build
dotnet test
dotnet packMIT — see LICENSE.
Runtime dependency: WinFsp (GPLv3 with FLOSS exception). WinFsp must be installed on the target machine. This binding library does not redistribute WinFsp binaries.