I have the latest release version of CommunityToolkit.Maui (5.0.0).
When I run CommunityToolkit.Maui.Storage.FileSaver in my app on iOS I get a strange user interaction. The window shown looks like that in the iOS_FileSaver.png image attached. The filename is a GUID number. The fileName string I enter in SaveAsync has no influence at all.
If however I run the git@github.com:CommunityToolkit/Maui.git/ essentials / FileSaver using static FileSaver on iOS the I get the result in the attached CommunityToolkit.Maui.png Image
I can't find out why that is. My code looks very much like the code in git@github.com:CommunityToolkit/Maui.git/ essentials / FileSaver using static FileSaver example. My code:
public async Task<FileSaverResult> SaveToTextFile(MemoryStream TheStream, string filename)
{
try
{
return await FileSaver.Default.SaveAsync("/", "Test.txt", TheStream, default);
}
catch (Exception e)
{
var msg = $"File is not saved, {e.ToString()}";
await Shell.Current.DisplayAlert("Error", msg, "OK");
System.Diagnostics.Debug.WriteLine("SaveToTextFile failed: {0}", e.ToString());
return null;
}
finally
{
}
}
git@github.com:CommunityToolkit/Maui.git/ essentials / FileSaver using static FileSaver example code:
[RelayCommand]
async Task SaveFileStatic(CancellationToken cancellationToken)
{
using var stream = new MemoryStream(Encoding.Default.GetBytes("Hello from the Community Toolkit!"));
var fileSaveResult = await FileSaver.SaveAsync("DCIM", "test.txt", stream, cancellationToken);
if (fileSaveResult.IsSuccessful)
{
await Toast.Make($"File is saved: {fileSaveResult.FilePath}").Show(cancellationToken);
}
else
{
await Toast.Make($"File is not saved, {fileSaveResult.Exception.Message}").Show(cancellationToken);
}
}
What is the difference ? I very much prefer the git@github.com:CommunityToolkit/Maui.git/ essentials / FileSaver using static FileSaver example version.
-
Eigil