Вот мой тестовый код с некоторыми бессмысленными данными:
Код: Выделить всё
private async void DoExportAsync()
{
// write some data to a temporary file
string tempPath = Path.Combine(FileSystem.CacheDirectory, Guid.NewGuid().ToString() + ".tmp");
try
{
using (var writer = new StreamWriter(tempPath))
{
writer.WriteLine("Test");
writer.Flush();
}
// Now copy content to the final file that the user selects
string? finalPath = await FileUtils.SaveFileAsync(tempPath, "PackerData", ".txt");
// Display a message on success
if (finalPath != null)
await App.Current.Windows[0].Page!.DisplayAlert("Export", $"Gespeichert unter:\n{finalPath}", "OK");
}
finally
{
// delete the temporary file
if (File.Exists(tempPath))
File.Delete(tempPath);
}
}
Код: Выделить всё
await CommunityToolkit.Maui.Storage.FileSaver.Default.SaveAsync(...)
Однако этот код хорошо работает в эмуляторе Android, когда отладчик не подключен. (Я еще не проверял поведение на реальном смартфоне.)
Есть идеи, как обойти эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/797 ... h-debugger
Мобильная версия