jfversluis / FilePicker-Plugin-for-Xamarin-and-Windows

FilePicker Plugin for Xamarin and Windows
MIT License
157 stars 80 forks source link

Error to pick file .json or .xml on Download folder Android #187

Closed soniatrs closed 4 years ago

soniatrs commented 4 years ago

Expected Behavior

File Picker is openned, the user selects a file .json or .xml in Download folder File Picker is closed and the file data is returned

Actual Behavior

The File Picker is openned user selects the file (.json or .xml) in Download folder The app goes to a exception. It work fine if the .json or .xml files are picked from another folder (ex: DCIM Folder) No issue for .jpg, .pdf files that are correctly picked from download folder

private async void OnAddButton_Clicked(object sender, EventArgs e) { try {
FileData fileData = await CrossFilePicker.Current.PickFile(); if (fileData == null) return; // user canceled file picking

string fileName = fileData.FileName;
string contents = System.Text.Encoding.UTF8.GetString(fileData.DataArray);

await DisplayAlert("File name chosen: ", fileName, "Ok");
await DisplayAlert("File data: ", contents, "Ok");
}
catch (Exception ex)
{
await DisplayAlert("Errore: ", "Eccezione nella scelta del file: " + ex.ToString(), "Ok");
}

}

stack trace: Eccezione nella scelta del file: System.FormatException: Input string was not in a correct format. at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corert/src/System.Private.CoreLib/shared/System/Number.Parsing.cs:1781 at System.Number.ParseInt64 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corert/src/System.Private.CoreLib/shared/System/Number.Parsing.cs:246 at System.Int64.Parse (System.String s) [0x0000a] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Int64.cs:106 at Plugin.FilePicker.IOUtil.GetPath (Android.Content.Context context, Android.Net.Uri uri) [0x000ab] in D:\a\1\s\src\Plugin.FilePicker\Android\IOUtil.android.cs:64 at Plugin.FilePicker.FilePickerActivity.OnActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data) [0x00039] in D:\a\1\s\src\Plugin.FilePicker\Android\FilePickerActivity.android.cs:151 --- End of stack trace from previous location where exception was thrown ---

at Plugin.FilePicker.FilePickerImplementation.PickFile (System.String[] allowedTypes) [0x00028] in D:\a\1\s\src\Plugin.FilePicker\Android\FilePickerImplementation.android.cs:60 at AIDApro.Views.ArchivioPage.OnAddButton_Clicked (System.Object sender, System.EventArgs e) [0x000f6] in C:\z-MICRODATA\AIDApro\AIDApro\Views\ArchivioPage.xaml.cs:57

Steps to Reproduce the Problem

1. 1. 1.

Specifications

vividos commented 4 years ago

Please update to the latest beta version, 2.1.41-beta, where this bug is already fixed. @jfversluis I think we should make a release build to update the stable NuGet, so that fewer people fall into this trap.

soniatrs commented 4 years ago

Thank you for the quick response! It works. I will consider this issue closed.

jfversluis commented 4 years ago

@vividos published that version as stable

vividos commented 4 years ago

Thanks Gerald!