无法从Windows Phone 8应用程序上传文件 [英] Unable to upload file from a Windows Phone 8 app
问题描述
我正在尝试将一个位于MemoryStream中的GPX文件上传到SkyDrive。以下是相关代码:
//开始上传过程。首先检查我们在Skydrive中是否有足够的空间...
LiveConnectClient客户端=新的LiveConnectClient(App.Client.Session);
if(client!= null)
{
LiveOperationResult quotaResult = await client.GetAsync(" me / skydrive / quota");
if(quotaResult.Result.ContainsKey(" available"))
{
Int64 available = Convert.ToInt64(quotaResult.Result [" available"]);
if(可用> = memStream.Length)
{
尝试
{
LiveOperationResult uploadResult = await client.UploadAsync(" me / skydrive",fileName, memStream,OverwriteOption.Rename);
ProgressIndicatorIsVisible = false;
}
catch(例外e)
{
DialogMessage message = new DialogMessage(e.Message,DialogMessageCallback);
}
}
else
{
DialogMessage message = new DialogMessage(AppResources.SkydriveFull,DialogMessageCallback);
Messenger.Default.Send< DialogMessage>(消息);
}
}
}
我遇到的问题是它似乎等待了一段时间,然后抛出以下异常在client.UploadAsync()行:
client_error:Microsoft.Live.LiveConnectException:抛出了类型'Microsoft.Live.LiveConnectException'的异常。
这是在手机上运行(我的电脑无法运行模拟器),无论手机是连接到WiFi还是移动数据,都会出现。
我做错了什么?
异常中是否还有其他信息 - 消息,堆栈跟踪等。 ?
I'm trying to upload a GPX file, which is in a MemoryStream, to SkyDrive. Here's the relevant code :
// Start the upload process. First check we have enough space in the Skydrive... LiveConnectClient client = new LiveConnectClient(App.Client.Session); if (client != null) { LiveOperationResult quotaResult = await client.GetAsync("me/skydrive/quota"); if (quotaResult.Result.ContainsKey("available")) { Int64 available = Convert.ToInt64(quotaResult.Result["available"]); if (available >= memStream.Length) { try { LiveOperationResult uploadResult = await client.UploadAsync("me/skydrive", fileName, memStream, OverwriteOption.Rename); ProgressIndicatorIsVisible = false; } catch (Exception e) { DialogMessage message = new DialogMessage(e.Message, DialogMessageCallback); } } else { DialogMessage message = new DialogMessage(AppResources.SkydriveFull, DialogMessageCallback); Messenger.Default.Send<DialogMessage>(message); } } }
The problem I'm having is that it seems to wait for a while, then throw the following exception on the client.UploadAsync() line:
client_error: Microsoft.Live.LiveConnectException: Exception of type 'Microsoft.Live.LiveConnectException' was thrown.
This is being run on a phone (my computer won't run the emulator), and occurs whether the phone is connected to WiFi or mobile data.
What am I doing wrong?
Is there any more information in the exception - message, stack trace, etc.?
这篇关于无法从Windows Phone 8应用程序上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!