Reputation: 1330
In a maui blazor app I created the folder wwwroot/audio and put some files there. How can I get all the filenames from this directory?
string mainDir = FileSystem.Current.AppDataDirectory;
var audioFiles = Directory.GetFiles(Path.Combine(mainDir, "/wwwroot/audio"));
Didn't work!
Upvotes: 3
Views: 2387
Reputation: 14639
It seems you can't get the file directly. But you can get it by reading the file. Such as:
using var stream = await FileSystem.OpenAppPackageFileAsync("wwwroot/audio");
I have done a sample to test and I can get the string in the txt file with a streamreader. If you need more information, please check the official document.
Upvotes: 4