如何通过控制台应用程序将文件上传到OneDrive? [英] How to upload file to OneDrive through console app?
问题描述
我正在尝试从控制台应用程序中将文件上传到 OneDrive .在深入研究Google之后,我发现了 Live SDK ,但我找不到查找使用 Live SDK 逐步演示文件上传的任何文章.有没有很好的资源解释如何做?谢谢.
I am trying to upload a file to OneDrive from within console app. After digging a bit into Google I found Live SDK but I couldn't find any article demonstrating file upload step by step using Live SDK. Is there any good resource explaining how to it? Thanks.
推荐答案
LiveSDK具有大量示例和模板代码,这些示例和模板代码托管在Github上, https://github.com/liveservices/LiveSDK-for-Windows .
The LiveSDK has a number of examples and template code that are hosted on Github, https://github.com/liveservices/LiveSDK-for-Windows.
To see an example of how uploading is down you can explore the sample applications located at https://github.com/liveservices/LiveSDK-for-Windows/blob/master/src/Desktop/Samples/ApiExplorer/MainForm.cs#L259
以下是ApiExplorer示例应用程序的摘录:
Here is a snippet from the ApiExplorer example application:
OpenFileDialog dialog = new OpenFileDialog();
Stream stream = null;
dialog.RestoreDirectory = true;
if (dialog.ShowDialog() != DialogResult.OK)
{
throw new InvalidOperationException("No file is picked to upload.");
}
try
{
if ((stream = dialog.OpenFile()) == null)
{
throw new Exception("Unable to open the file selected to upload.");
}
using (stream)
{
return await this.liveConnectClient.UploadAsync(path, dialog.SafeFileName, stream, OverwriteOption.DoNotOverwrite);
}
}
catch (Exception ex)
{
throw ex;
}
这篇关于如何通过控制台应用程序将文件上传到OneDrive?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!