我用于将文件上传到Dropbox的代码非常简单...但是它永远不会从对UploadAsync的调用中返回...文件实际上实际上完美地存在于Dropbox中,但是它从未从函数调用中返回...任何知道我可能在做错什么吗?
using Dropbox.Api;
using Dropbox.Api.Files;
using System;
using System.IO;
using System.Threading.Tasks;
namespace Test
{
public static class DropboxService
{
private static string DropboxAccessToken = "...";
public async static Task<bool> UploadFile(Stream stream, string path, string filename)
{
using (var client = new DropboxClient(DropboxAccessToken))))
{
var updated = await client.Files.UploadAsync(
Path.Combine(path, filename),
WriteMode.Overwrite.Instance,
body: stream);
// never returns from UploadAsync
}
return true;
}
}
}
答案 0 :(得分:0)
我不知道为什么,但这对我有用。
var response = dbx.Files.UploadAsync(folder +“ /” + file,WriteMode.Overwrite.Instance,body:stream).Result;