VirtualFS
VirtualFS is a .NET library for composing multiple file-like data sources into one virtual hierarchy.
The core model is:
- every backend implements
IFileSystem - a
RootFileSystemmounts many backends under virtual paths - callers interact with virtual paths like
/assets/logo.png - reads and writes are dispatched to the mounted backend that owns that path
It behaves more like a small VFS layer than a thin System.IO wrapper.
Status
The project currently targets:
netstandard2.0net472net6.0net8.0net10.0
The test project targets net10.0.
Key Rules
- paths are always rooted
/foo/is a directory/foois a file- trailing
/defines directory vs file - path separator is always
/ - mounted filesystems can overlap
- mount priority controls lookup order
Minimal Example
using System.IO;
using VirtualFS;
using VirtualFS.Implementation;
using VirtualFS.Memory;
using VirtualFS.Physical;
var root = new RootFileSystem();
root.Mount(new PhysicalFileSystem(new DirectoryInfo("./content")), "/");
root.Mount(new MemoryFileSystem { Priority = FileSystemMountPriority.High }, "/");
root.Root.FileCreate("runtime.txt").WriteAllText("generated at runtime");
foreach (var entry in root.Root.GetEntries())
{
Console.WriteLine($"{entry.FullPath} readonly={entry.IsReadOnly}");
}
Documentation
Detailed documentation is split into the docs/ folder:
Build and Test
The repository includes a Docker-based build/test flow using the official .NET 10 SDK image.
docker build --target test -t virtualfs:test .
The repository CI runs the same Docker target on pushes and pull requests.
License
The project metadata declares the MIT license.
Description
Languages
C#
99.8%
Dockerfile
0.2%