Closed ralpholazo24 closed 5 years ago
Could you update to the latest version and see if the issue still exists?
Also, the whole output from ex.ToString() world be interesting!
Could you update to the latest version and see if the issue still exists?
It stills throw the error. I already update it to Xamarin.Plugin.FilePicker -Version 2.1.34
This is only happens when I pick a file from download folder. I already try it to the other devices, and it still gives me that error.
Also, the whole output from ex.ToString() world be interesting!
at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x0004d] in /Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/number.cs:1074
at System.Number.ParseInt64 (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) [0x00014] in /Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/number.cs:766
at System.Int64.Parse (System.String s) [0x00000] in /Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/int64.cs:114
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+
Could you try out the sample project in this repository, set a breakpoint at Plugin.FilePicker.IOUtil.GetPath() where the long value is parsed and tell us the Uri and the I'd that the code wants to parse? Thanks!
So here is what I've notice on the code.
@vividos any updates?
I looked at the images, and it seems the code that parses content URIs from DocumentsContract doesn't recognize all variants of URIs that can occur. I always thought that the code is brittle, as it assumed how URIs are constructed. The best way to fix this would be to replace long.Parse
with TryParse
and just return null when it doesn't parse. If you can come up with a PR, we're happy to incorporate it into FilePicker plugin. After all, the plugin is open source! I have limited time at the moment. Sorry!
Sounds good. Sure, I will try it and have a PR for it.
@ralpholazo24 and @vividos I am having same issue. Any timeline to fix this? I would be happy to create a PR.
@mayank1214 if you have time to fix this, why not! The task should be simple: Replace the long.Parse() call with a long.TryParse() call and return null when the parsing failed. Returning null from that function ensures that the original content:// URL is returned. In this case the caller must use GetStream() to access the picked data, as it's the only way.
@vividos Here is the PR request . I am new to Xamarin and this my first project. I encountered a weird issue while working on this PR and hoping someone can help me to figure out the answer. My local variables were not displaying values on debug watcher. Any idea why? See below screenshot
I was also getting "System.FormatException: 'Input string was not in a correct format.' inconsistently. I had purposely set CLR Exception to get more information about that error.
Note: Fixed in version 2.1.36-beta.
Expected Behavior
Pick a file from download folder. But aside in download folder, I can choose files in different folders.
Actual Behavior
It throws an error "Input string was not in a correct format."
Here is my code:
fileData = await CrossFilePicker.Current.PickFile(); if (fileData == null) return;
I also have the permission to read and write in storage. Does someone also encounter this error?