我正在尝试使用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);
}
但是我得到这样的错误
任何人都可以指导我.....
提前致谢。
答案 0 :(得分:2)
有时MSDN文档可能非常混乱。
PickSingleFileAsync(); // is not supported
而是试试这个:
PickSingleFileAndContinue();
MSDN PickSingleFileAndContinue