How can I use File.ReadAllBytes()
to read a file from the Assets
folder into a byte[]
? Therefore I need a filepath. I tried with ms-appx-web:///Assets/test.jpg
, but that didn't worked. File.Exists()
return false.
How do I get the absolute path to the assets folder?
This fragment shoud do,
string fname = @"Assets\test.jpg";
StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFile file = await InstallationFolder.GetFileAsync(fname);
if(File.Exists(file.Path))
{
var contents = File.ReadAllBytes(file.Path);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With