使用文件选择器获取 "Input string was not in a correct format"
Getting "Input string was not in a correct format" with File picker
我正在尝试使用以下代码选择一个文件
FileData fileData = new FileData();
fileData = await CrossFilePicker.Current.PickFile();
if (fileData != null)
并得到以下异常
at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overfl
owResourceKey) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/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/2020-02/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/2020-02/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\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\s\src\Plugin.FilePicker\Android\FilePickerActivity.android.cs:151
--- End of stack trace from previous location where exception was thrown ---
异常消息显示“输入的字符串格式不正确”。
我试了这么久,还是找不到解决办法
Android 版本 - 10
I am using the latest stable version for Xamarin.Essentials but
FilePickerAsync() is not accessible.
在Xamarin.Essentials的最新版本中,得到:
using Xamarin.Essentials;
public async void getFile()
{
var result = await FilePicker.PickAsync();
//...
}
需要 ReadExternalStorage
权限:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
我正在尝试使用以下代码选择一个文件
FileData fileData = new FileData();
fileData = await CrossFilePicker.Current.PickFile();
if (fileData != null)
并得到以下异常
at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overfl
owResourceKey) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/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/2020-02/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/2020-02/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\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\s\src\Plugin.FilePicker\Android\FilePickerActivity.android.cs:151
--- End of stack trace from previous location where exception was thrown ---
异常消息显示“输入的字符串格式不正确”。
我试了这么久,还是找不到解决办法
Android 版本 - 10
I am using the latest stable version for Xamarin.Essentials but FilePickerAsync() is not accessible.
在Xamarin.Essentials的最新版本中,得到:
using Xamarin.Essentials;
public async void getFile()
{
var result = await FilePicker.PickAsync();
//...
}
需要 ReadExternalStorage
权限:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />