I'm using the new Dropbox SDK v2 for .NET.
I'm trying to upload a document to a Dropbox account.
public async Task UploadDoc()
{
using (var dbx = new DropboxClient("XXXXXXXXXX"))
{
var full = await dbx.Users.GetCurrentAccountAsync();
await Upload(dbx, @"/MyApp/test", "test.txt","Testing!");
}
}
async Task Upload(DropboxClient dbx, string folder, string file, string content)
{
using (var mem = new MemoryStream(Encoding.UTF8.GetBytes(content)))
{
var updated = await dbx.Files.UploadAsync(
folder + "/" + file,
WriteMode.Overwrite.Instance,
body: mem);
Console.WriteLine("Saved {0}/{1} rev {2}", folder, file, updated.Rev);
}
}
This code snippet actually creates a test.txt document on the Dropbox account with the "Testing!" content, but I want to upload a document, with a given path (for example: "C:\MyDocuments\test.txt"), is that possible?
Any help would be very much appreciated.