async private void uploadtosky_Click(object sender, RoutedEventArgs e)
{
try
{
LiveAuthClient auth = new LiveAuthClient();
LiveLoginResult log = await auth.LoginAsync(new List<string> { "wl-basic", "wl.skydrive", "wl.signin" });
if (log.Status == LiveConnectSessionStatus.Connected)
{
LiveConnectClient uploadcl = new LiveConnectClient(auth.Session);
LiveOperationResult up = await uploadcl.BackgroundUploadAsync("me/skydrive", heading.Text, samplefile, OverwriteOption.Overwrite);
}
}
catch
{
MessageDialog msg = new MessageDialog("Oops ! something went wrong while trying to connect");
msg.ShowAsync();
}
}
当我执行代码段时messagebox
显示Oops ! something went wrong while trying to connect
。我的计算机已连接到互联网,点击按钮进行上传后,我在Windows 8应用程序中获得了登录页面的真实帐户。但是我猜它无法登录帐户,因此发生异常。有没有想过克服这个问题?
答案 0 :(得分:0)
你的档案有多大?它是否大于300MB?我记得大文件在上传方面存在一些问题。
答案 1 :(得分:0)
终于找到了答案。实际上需要将auth.Session替换为log.Session(在行LiveConnectClient uploadcl = new LiveConnectClient(auth.Session);
中)并在LiveLoginResult log = await auth.LoginAsync(new List<string> { "wl-basic", "wl.skydrive", "wl.signin" });
中添加名为wl.skydrive_update的作用域
多数民众赞成!