Meziantou.Framework.Win32.ProjectedFileSystem 2.0.10

Prefix Reserved
dotnet add package Meziantou.Framework.Win32.ProjectedFileSystem --version 2.0.10
                    
NuGet\Install-Package Meziantou.Framework.Win32.ProjectedFileSystem -Version 2.0.10
                    
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="Meziantou.Framework.Win32.ProjectedFileSystem" Version="2.0.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Framework.Win32.ProjectedFileSystem" Version="2.0.10" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.Framework.Win32.ProjectedFileSystem" />
                    
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 Meziantou.Framework.Win32.ProjectedFileSystem --version 2.0.10
                    
#r "nuget: Meziantou.Framework.Win32.ProjectedFileSystem, 2.0.10"
                    
#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 Meziantou.Framework.Win32.ProjectedFileSystem@2.0.10
                    
#: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=Meziantou.Framework.Win32.ProjectedFileSystem&version=2.0.10
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.Framework.Win32.ProjectedFileSystem&version=2.0.10
                    
Install as a Cake Tool

Meziantou.Framework.Win32.ProjectedFileSystem

A .NET wrapper for the Windows Projected File System (ProjFS) API, enabling you to create virtual file systems that appear as normal files and folders to users and applications.

Requirements

  • 64-bit process only
  • Windows 10 version 1809 or later (with the "Projected File System" optional feature installed)
Enable-WindowsOptionalFeature -Online -FeatureName Client-ProjFS -NoRestart

Usage

Basic Example

Create a virtual file system by inheriting from ProjectedFileSystemBase and implementing the required abstract methods:

using Meziantou.Framework.Win32.ProjectedFileSystem;

public class MyVirtualFileSystem : ProjectedFileSystemBase
{
    public MyVirtualFileSystem(string rootFolder) : base(rootFolder)
    {
    }

    // Return the list of files and folders for a given path
    protected override IEnumerable<ProjectedFileSystemEntry> GetEntries(string path)
    {
        if (string.IsNullOrEmpty(path))
        {
            yield return ProjectedFileSystemEntry.Directory("folder");
            yield return ProjectedFileSystemEntry.File("file1.txt", length: 100);
            yield return ProjectedFileSystemEntry.File("file2.txt", length: 200);
        }
        else if (AreFileNamesEqual(path, "folder"))
        {
            yield return ProjectedFileSystemEntry.File("nested.txt", length: 50);
        }
    }

    // Return a stream to read the file content
    protected override Stream OpenRead(string path)
    {
        if (AreFileNamesEqual(path, "file1.txt"))
        {
            return new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!"));
        }
        else if (AreFileNamesEqual(path, "file2.txt"))
        {
            return new MemoryStream(Encoding.UTF8.GetBytes("Another file content"));
        }
        else if (AreFileNamesEqual(path, "folder\\nested.txt"))
        {
            return new MemoryStream(Encoding.UTF8.GetBytes("Nested file"));
        }

        return null;
    }
}

// Start the virtual file system
var rootPath = @"C:\MyVirtualFS";
Directory.CreateDirectory(rootPath);

using var vfs = new MyVirtualFileSystem(rootPath);
vfs.Start(options: null);

// The files are now accessible through Windows Explorer or any application
var content = File.ReadAllText(Path.Combine(rootPath, "file1.txt")); // "Hello, World!"

Advanced Options

Configure the virtual file system with start options:

var options = new ProjectedFileSystemStartOptions
{
    // Enable caching of non-existent file paths for better performance
    UseNegativePathCache = true,

    // Subscribe to file system notifications
    Notifications =
    {
        new Notification(
            PRJ_NOTIFY_TYPES.FILE_OPENED |
            PRJ_NOTIFY_TYPES.NEW_FILE_CREATED |
            PRJ_NOTIFY_TYPES.FILE_RENAMED |
            PRJ_NOTIFY_TYPES.PRE_DELETE)
    }
};

vfs.Start(options);

Key Classes

ProjectedFileSystemBase

The base class for creating a virtual file system. Override these methods:

  • GetEntries(string path): Returns the files and folders for a given directory path
  • OpenRead(string path): Returns a stream to read file content
  • GetEntry(string path) (optional): Returns metadata for a specific file or folder

Protected helper methods:

  • FileNameMatch(string fileName, string pattern): Checks if a filename matches a pattern
  • AreFileNamesEqual(string fileName1, string fileName2): Case-insensitive file name comparison
  • CompareFileName(string fileName1, string fileName2): Compare file names with proper sorting
  • ClearNegativePathCache(): Clear the negative path cache
  • DeleteFile(string relativePath, PRJ_UPDATE_TYPES updateFlags, out PRJ_UPDATE_FAILURE_CAUSES failureReason): Delete a file from the projection

ProjectedFileSystemEntry

Represents a file or folder in the virtual file system:

// Create a file entry
var file = ProjectedFileSystemEntry.File("example.txt", length: 1024);

// Create a folder entry
var folder = ProjectedFileSystemEntry.Directory("MyFolder");

Properties:

  • Name: File or folder name
  • IsDirectory: Whether this is a directory
  • Length: File size in bytes (0 for directories)

ProjectedFileSystemStartOptions

Configuration options when starting the file system:

  • UseNegativePathCache: Cache queries for non-existent paths to improve performance
  • Notifications: List of notification subscriptions

PRJ_FILE_STATE (Enum)

Query the on-disk state of a file:

var state = ProjectedFileSystemBase.GetOnDiskFileState(@"C:\MyVirtualFS\file.txt");

States:

  • PRJ_FILE_STATE_PLACEHOLDER: Virtual file (not yet hydrated)
  • PRJ_FILE_STATE_HYDRATED_PLACEHOLDER: File content downloaded
  • PRJ_FILE_STATE_DIRTY_PLACEHOLDER: Modified placeholder
  • PRJ_FILE_STATE_FULL: Full file (no longer managed by ProjFS)
  • PRJ_FILE_STATE_TOMBSTONE: Deleted placeholder

Additional Resources

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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.10 87 2/15/2026
2.0.9 7,832 11/2/2025
2.0.8 1,594 10/27/2025
2.0.7 192 10/26/2025
2.0.6 138 10/19/2025
2.0.5 3,250 9/3/2025
2.0.4 22,075 11/17/2024
2.0.3 366 11/15/2023
2.0.2 585 7/14/2021
2.0.1 502 4/22/2021
2.0.0 590 9/24/2020
1.0.2 647 6/25/2020
1.0.1 709 10/23/2019
1.0.0 866 1/12/2019