-
Place the files to be packaged in the
Resources\Raw\
directory. -
Set the file’s Build Action to
MauiAsset
. -
Use
using (Stream instream = FileSystem.Current.OpenAppPackageFileAsync(fileName))
to read the file. -
Copy the file to another directory.
1 2 3 4 5 6 7 8 9
// Open the source file using Stream inputStream = await FileSystem.Current.OpenAppPackageFileAsync(filename); // Create an output filename string targetFile = Path.Combine(FileSystem.Current.AppDataDirectory, filename); // Copy the file to the AppDataDirectory using FileStream outputStream = File.Create(targetFile); await inputStream.CopyToAsync(outputStream);