【发布时间】:2015-03-25 17:18:26
【问题描述】:
我是开发 Windows Phone 应用程序的新手。此外,我的笔记本电脑太旧了,无法在其上开发或使用 Emulator for Windows Phone 7.5 或更高版本,所以我必须坚持使用旧的 WP7.1
我想将选定的图像上传到谷歌驱动器。我创建了一个按钮来浏览图像和一个“图像容器”在选择后显示它。使用下面的代码在这里完成。但是在显示之后,我希望上传过程也从这里开始。但是问题一开始就出现了。
private void browseButton_Click(object sender, RoutedEventArgs e)
{
PhotoChooserTask photo = new PhotoChooserTask();
photo.ShowCamera = true;
photo.Show();
photo.Completed += new EventHandler<PhotoResult>(browseButton_Click_Conpleted);
}
private void browseButton_Click_Conpleted(object sender, PhotoResult e)
{
BitmapImage image = new BitmapImage();
image.SetSource(e.ChosenPhoto);
displayIMG.Source = image;
//It works until now
//Below is the code I copied from many place that will authorize me to upload to their drive.
string[] scopes = new string[] { DriveService.Scope.Drive,
DriveService.Scope.DriveFile};
UserCredential credential =
GoogleWebAuthorizationBroker
.AuthorizeAsync(new ClientSecrets
{
ClientId = "MY_CLIENT_ID_HERE"
,
ClientSecret = ""MY_SECRET_ID_HERE"
}
, scopes
, Environment.UserName
, CancellationToken.None
, new FileDataStore("Daimto.GoogleDrive.Auth.Store")
).Result;
}
它显示了很多错误,因为它无法识别某些类型或命名空间,不建议使用using。我创建了一个以 WP8.0 为目标的新项目,希望它能识别除Environment.UserName 或new FileDataStore 等仍然缺失的所有内容。我已经添加了Google.Apis.Drive.v2 client library 我不知道我错过了什么。
我的首要任务是在 WP7.1 上开发。我不想仅仅因为这个而购买新手机。对不起我的英语。
【问题讨论】:
标签: c# api windows-phone-8 google-api windows-phone