A file should be first marked as embedded resource to embed the file into the assembly. The easiest way to do it is to select the file from the **Solution Explorer** and set **Build Action** to **Embedded Resource** from the **Properties** window. Example:
A file should be first registered in order to use it in the application. Example:
If you want to add multiple files, this can be tedious. Alternatively, you can directly edit your **.csproj** file:
````C#
<ItemGroup>
<NoneRemove="MyResources\**\*.*"/>
</ItemGroup>
````
This configuration recursively adds all files under the **MyResources** folder of the project (including the files you will add in the future).
Then the module should configure `VirtualFileSystemOptions` to register embedded files to the virtual file system. Example:
````C#
using Microsoft.Extensions.DependencyInjection;
@ -58,6 +70,38 @@ namespace MyCompany.MyProject
}
````
AddEmbedded extension method takes a
`AddEmbedded` extension method takes a class, finds all embedded files from the assembly of the given class and register to the virtual file system. It's a shortcut and could be written as shown below:
After embedding a file into an assembly and registering to the virtual file system, `IVirtualFileProvider` can be used to get files or directory contents: