SpawnDev.AsyncFileSystem
1.1.0
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
<PackageReference Include="SpawnDev.AsyncFileSystem" Version="1.1.0" />
<PackageVersion Include="SpawnDev.AsyncFileSystem" Version="1.1.0" />
<PackageReference Include="SpawnDev.AsyncFileSystem" />
paket add SpawnDev.AsyncFileSystem --version 1.1.0
#r "nuget: SpawnDev.AsyncFileSystem, 1.1.0"
#:package SpawnDev.AsyncFileSystem@1.1.0
#addin nuget:?package=SpawnDev.AsyncFileSystem&version=1.1.0
#tool nuget:?package=SpawnDev.AsyncFileSystem&version=1.1.0
SpawnDev.AsyncFileSystem
Cross-platform async file system for .NET. Same API on desktop (native filesystem) and browser (OPFS — Origin Private File System).
Features
- Unified
IAsyncFSinterface — 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,GetWriteStreamfor large files - JSON serialization:
ReadJSON<T>,WriteJSONbuilt-in - File system change events:
FileSystemChangedevent - 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 storage — SpawnDev.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 | Versions 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. |
-
net10.0
- SpawnDev.BlazorJS (>= 3.5.0)
-
net8.0
- SpawnDev.BlazorJS (>= 3.5.0)
-
net9.0
- SpawnDev.BlazorJS (>= 3.5.0)
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.