No description or website provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Branch Build Status NuGet
Master Build master NuGet
Develop Build develop NuGet


Provides some useful IFileProvider implementations for core. Current FileProvider Implementations include:

  • RequestPathFileProvider
  • InMemoryFileProvider


This file provider can wrap an existing IFileProvider but allows you to prepend information to the path that it's files are resolved on.

For example, let's say you have an IFileProvider which resolves a file on the subpath /myfile.txt, however, when you serve the file using MVC in the browser, you want it's path to be /specialfiles/myfile.txt.

You can do this:

            var originalFileProvider = new PhysicalFileProvider(someDir);
            var sut = new RequestPathFileProvider("/specialfiles", originalFileProvider);

Now you can resolve exactly the same files and directories through the RequestPathFileProvider that the original FileProvider has, but you must do so using subpaths that have /specialfiles prepended.


Allows you to provide files from an in memory directory. For example:

             // Arrange
            var provider = new InMemoryFileProvider();
            provider.Directory.AddFile("/some/path/", new StringFileInfo("file contents", "foo.txt"));
            // Act
            var fileInfo = provider.GetFileInfo("/some/path/foo.txt");

            // Assert

The file provider wraps an IDirectory which supports the kind of operations you would expect of a directory. You can set up the directory first, or perform operations on the IDirectory independent of the file provider.

For example:

            // Arrange
            IDirectory directory = new InMemoryDirectory();

            // Act
            // Adds the specified folder structure to this directory:
            var folder = directory.GetOrAddFolder("/some/dir/folder");
            // could add / update, delete files in this directory etc.

            var provider = new InMemoryFileProvider(directory);           

You can add, update, delete files in the IDirectory as you might expect. You can use the StringFileInfo class which represents in memory file.

The following adds a file to the directory at /some/dir/foo.txt with the contents "contents":

var file = directory.AddFile("/some/dir", new StringFileInfo("contents","foo.txt"));

The InMemoryFileProvider fully supports watching and change tokens. Which means if you add / update / delete a file or folder in the directory, the appropriate change tokens will be signalled.