I'm currently working on a .NET Standard 2.1 Blazor WebAssembly application. I try to read file paths from my wwwroot directory.
The Blazor WebAssembly App is NOT Asp.NET Core hosted.
I try to read all file paths with the ending .js from my Main
method in the Program.cs
like this:
var filePaths = ReadWwwRootJSFilePaths();
private static string[] ReadWwwRootJSFilePaths()
{
Console.WriteLine("CurrentDirectory: " + Directory.GetCurrentDirectory());
var dir = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "js");
Console.WriteLine("dir: " + dir);
var files = Directory.GetFiles(dir);
foreach (string file in files)
{
Console.WriteLine("file: " + file);
}
return files;
}
When I run this I only get an error message in my browser: System.IO.DirectoryNotFoundException
Do you know how to solve this problem? Do you know how to read file paths from the wwwroot
dir in a Blazor WASm (not ASP.NET Core hosted) application?
Perhaps yet I don't quite get the concept of Blazor WebAssembly (not ASP.NET Core hosted). Is it actually possible to use C# .NET Core functionalities?