We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
user3378165
10 years agoExplorer | Level 3
Upload a file with a given path
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.
2 Replies
- Mark10 years ago
Super User II
*moves to API forum* - Greg-DB10 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/40973321/is-it-possible-to-upload-a-file-to-dropbox-api-v2-0-with-a-path ]
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!