SpawnDev.AsyncFileSystem 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SpawnDev.AsyncFileSystem --version 1.1.0
                    
NuGet\Install-Package SpawnDev.AsyncFileSystem -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SpawnDev.AsyncFileSystem" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SpawnDev.AsyncFileSystem" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SpawnDev.AsyncFileSystem" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SpawnDev.AsyncFileSystem --version 1.1.0
                    
#r "nuget: SpawnDev.AsyncFileSystem, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SpawnDev.AsyncFileSystem@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SpawnDev.AsyncFileSystem&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SpawnDev.AsyncFileSystem&version=1.1.0
                    
Install as a Cake Tool

SpawnDev.AsyncFileSystem

NuGet License: MIT

Cross-platform async file system for .NET. Same API on desktop (native filesystem) and browser (OPFS — Origin Private File System).

Features

  • Unified IAsyncFS interface — one API for both platforms
  • Browser: OPFS via FileSystemDirectoryHandle (persistent, survives page reloads)
  • Desktop: Native filesystem via System.IO
  • Full file operations: Read, Write, Append, Delete, Directory management
  • Stream support: GetReadStream, GetWriteStream for large files
  • JSON serialization: ReadJSON<T>, WriteJSON built-in
  • File system change events: FileSystemChanged event
  • Path utilities: Cross-platform path manipulation via IOPath

Quick Start

Browser (Blazor WASM) — OPFS

using SpawnDev.AsyncFileSystem;
using SpawnDev.AsyncFileSystem.BrowserWASM;

// Get the OPFS root directory
var fs = new AsyncFSFileSystemDirectoryHandle();

// Write and read files — persists across page reloads
await fs.Write("data/config.json", """{"setting": true}""");
var config = await fs.ReadText("data/config.json");

// Binary data
await fs.Write("data/model.bin", modelBytes);
var bytes = await fs.ReadBytes("data/model.bin");

Desktop (.NET) — Native Filesystem

using SpawnDev.AsyncFileSystem;
using SpawnDev.AsyncFileSystem.Native;

var fs = new AsyncFSNative("/path/to/data");

await fs.Write("cache/piece_0", pieceData);
var data = await fs.ReadBytes("cache/piece_0");

API Reference

IAsyncFS

Method Description
Write(path, byte[]) Write binary data
Write(path, string) Write text
Write(path, Stream) Write from stream
ReadBytes(path) Read as byte array
ReadText(path) Read as string
ReadStream(path) Get read stream
Append(path, data) Append to file
ReadJSON<T>(path) Deserialize JSON file
WriteJSON(path, obj) Serialize to JSON file
FileExists(path) Check if file exists
DirectoryExists(path) Check if directory exists
Exists(path) Check if path exists
CreateDirectory(path) Create directory
Remove(path, recursive) Delete file or directory
GetFiles(path) List files in directory
GetDirectories(path) List subdirectories
GetEntries(path) List all entries
GetInfo(path) Get file/directory info
GetReadStream(path) Get read-only stream
GetWriteStream(path) Get writable stream

Use Cases

  • Torrent piece storageSpawnDev.WebTorrent uses this for persistent piece caching in the browser
  • ML model caching — Cache downloaded model weights in OPFS so they load instantly on return visits
  • Application data — Config files, user data, cached assets
  • Offline-first apps — Store data locally in the browser, sync when online

Credits

Built by Todd Tanner (@LostBeard) and the SpawnDev team.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SpawnDev.AsyncFileSystem:

Package Downloads
SpawnDev.WebTorrent

Pure C# BitTorrent/WebTorrent client. 15 BEPs, real WebRTC P2P (browser + desktop), DHT with mutable items (BEP 46 — AI agent communication), web seeds, media streaming with seeking via service worker, OPFS storage. Includes webtorrent-sw.js for COI headers + torrent streaming. No JavaScript dependencies. Runs on desktop (.NET + SIPSorcery) and browser (Blazor WASM + SpawnDev.BlazorJS). 444 unit tests.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 0 3/31/2026
1.2.0 0 3/31/2026
1.1.0 0 3/31/2026
1.0.0 71 3/28/2026