I am using FileSaver functionality in .NET MAUI. It works fine with Android but it does not open to download the file on targeting folder which later on give “Path does not exist error”.
Here is my code for reference:
byte[] bytes = feeHistoryViewModel.networkCalls.PostAsyncWithHeaderPDF("studentfeeaudit/receipt/-1/" + ob.PaymentId + "/" + ob.SessionId).Result;
if (bytes != null)
{
using var stream = new MemoryStream(bytes);
string fileName = AccountInfo.userAccount.Name + " " + ob.InvoiceNumber + " " + ob.Date + "_" + "fees.pdf";
var fileSaverResult = await fileSaver.SaveAsync(fileName, stream, cancellationTokenSource.Token);
fileSaverResult.EnsureSuccess();
var request = new NotificationRequest
{
NotificationId = 1000,
Title = fileName,
Description = fileSaverResult.FilePath,
ReturningData = fileSaverResult.FilePath // Returning data when tapped on notification.
};
await LocalNotificationCenter.Current.Show(request);
}
I use same byte array for Android but in iOS it does not show me to save the file on particular file path.
In Android
var fileSaverResult = await fileSaver.SaveAsync(fileName, stream, cancellationTokenSource.Token);
on execution it opens the UI so i could give the path for the folder where I want to save the file but in iOS it does not show me UI and execute next line after that which is:
fileSaverResult.EnsureSuccess();
which shows me error that file path does not exist.
I want it works same as it is working in Android.
Harshit Agarwal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.