FileOpenPicker无法使用phonegap工作windows phone 8.1

时间:2014-11-15 09:59:39

标签: c# cordova windows-phone windows-phone-8.1

我正在尝试使用phonegap在Windows Phone 8.1中使用FileOpenPicker选择一个文件,但它无效。

我使用此代码

public class Echo : BaseCommand { public void echo(string options) { try{ FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".jpeg"); openPicker.FileTypeFilter.Add(".png"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null){ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Picked photo: " + file.Name)); } else{ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Operation cancelled")); } }catch (Exception e){ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error=>"+e.ToString())); } } }

在phonegap中

cordova.exec(success, error, "Echo", "echo"); function success(message) { //upload_file(message); alert(message); } function error(e) { alert(e); }

但是我得到这样的错误

enter image description here

任何人都可以指导我.....

提前致谢。

1 个答案:

答案 0 :(得分:2)

有时MSDN文档可能非常混乱。

PickSingleFileAsync(); // is not supported

而是试试这个:

PickSingleFileAndContinue();

MSDN PickSingleFileAndContinue


enter image description here