Ramstack.FileProviders
2.7.3
dotnet add package Ramstack.FileProviders --version 2.7.3
NuGet\Install-Package Ramstack.FileProviders -Version 2.7.3
<PackageReference Include="Ramstack.FileProviders" Version="2.7.3" />
<PackageVersion Include="Ramstack.FileProviders" Version="2.7.3" />
<PackageReference Include="Ramstack.FileProviders" />
paket add Ramstack.FileProviders --version 2.7.3
#r "nuget: Ramstack.FileProviders, 2.7.3"
#:package Ramstack.FileProviders@2.7.3
#addin nuget:?package=Ramstack.FileProviders&version=2.7.3
#tool nuget:?package=Ramstack.FileProviders&version=2.7.3
Ramstack.FileProviders
Represents a .NET library that provides additional implementations of IFileProvider including:
PrefixedFileProviderSubFileProvider
Getting Started
To install the Ramstack.FileProviders NuGet package
in your project, run the following command:
dotnet add package Ramstack.FileProviders
PrefixedFileProvider
PrefixedFileProvider allows you to apply a prefix to the paths of files and directories.
This is useful when you need to organize files in a virtual hierarchy.
Example:
IFileProvider provider = new PrefixedFileProvider("/project/app", innerProvider);
IFileInfo file = provider.GetFileInfo("/project/app/docs/README");
Console.WriteLine(file.Exists);
This is how you can add virtual directories to your project that are outside the project root:
string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages");
string themesPath = Path.Combine(environment.ContentRootPath, "../Themes");
environment.ContentRootFileProvider = new CompositeFileProvider(
new PrefixedFileProvider("/Packages", new PhysicalFileProvider(packagesPath)),
new PrefixedFileProvider("/Themes", new PhysicalFileProvider(themesPath)),
environment.ContentRootFileProvider);
The Packages and Themes directories are now available to the ASP.NET infrastructure under their respective names,
as if they were originally defined within your project.
Before:
/App
├── Controllers
├── Models
├── Views
└── wwwroot
/Packages
├── package-1
└── package-2
/Themes
├── theme-1
└── theme-2
After:
/App
├── Controllers
├── Models
├── Views
├── Packages <-- (virtual)
│ ├── package-1
│ └── package-2
├── Themes <-- (virtual)
│ ├── theme-1
│ └── theme-2
└── wwwroot
SubFileProvider
SubFileProvider lets you limit the view of the file system to a specific subdirectory, effectively creating a sandbox.
Example:
IFileProvider provider = new SubFileProvider("/docs", innerProvider);
IFileInfo file = provider.GetFileInfo("/README");
Console.WriteLine(file.Exists);
Related Packages
- Ramstack.FileProviders.Extensions — Useful and convenient extensions for
IFileProvider, bringing its capabilities and experience closer to what's provided by theDirectoryInfoandFileInfoclasses. - Ramstack.FileProviders.Globbing — A file provider that filters files using include and/or exclude glob patterns. Include patterns make only matching files visible, while exclude patterns hide specific files. Both include and exclude patterns can be combined for flexible file visibility control.
- Ramstack.FileProviders.Composition — Provides a helper class for flattening and composing
IFileProvider.
Supported versions
| Version | |
|---|---|
| .NET | 6, 7, 8, 9, 10 |
Contributions
Bug reports and contributions are welcome.
License
This package is released as open source under the MIT License. See the LICENSE file for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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 was computed. 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. |
-
net6.0
- Microsoft.Extensions.FileProviders.Abstractions (>= 6.0.1)
- Ramstack.Globbing (>= 2.3.3)
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.7.3 | 87 | 4/2/2026 |
| 2.7.2 | 100 | 3/29/2026 |
| 2.7.1 | 94 | 3/28/2026 |
| 2.7.0 | 93 | 3/19/2026 |
| 2.6.0 | 479 | 8/31/2025 |
| 2.5.4 | 307 | 8/14/2025 |
| 2.5.3 | 256 | 7/31/2025 |
| 2.5.2 | 258 | 7/15/2025 |
| 2.5.1 | 219 | 7/9/2025 |
| 2.5.0 | 219 | 5/18/2025 |
| 2.4.1 | 204 | 5/17/2025 |
| 2.4.0 | 223 | 5/17/2025 |
| 2.3.0 | 234 | 4/23/2025 |
| 2.2.1 | 248 | 9/14/2024 |
| 2.2.0 | 185 | 9/14/2024 |
| 2.1.0 | 196 | 8/28/2024 |
| 2.1.0-preview.3 | 119 | 8/27/2024 |
| 2.1.0-preview.2 | 123 | 8/26/2024 |
| 2.1.0-preview.1 | 144 | 8/21/2024 |