简体   繁体   中英

Uploading to a folder other than root in Dropbox with SharpBox

I am having a problem to upload to any folder other than root in Dropbox using SharpBox. I can upload using this path var publicFolder = dropBoxStorage.GetFolder("/"); , but not to folder created in root, such as "/MyFolder". I can enumerate files using this path var publicFolder = dropBoxStorage.GetFolder("/MyFolder"); , but not upload there. Exception says: not authorized. How do I assign permissions to folders in root or is the problem in the app permissions? I appreciate any help.

Steps:

  1. Created account
  2. Created app on Dropbox with Full dropbox access
  3. Created console application in C#
  4. Installed Sharpbox using NuGet
  5. Generated token using keys provided by the app
  6. Coded

Here is the code:

        CloudStorage dropBoxStorage = new CloudStorage();

        var dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox);

        ICloudStorageAccessToken accessToken = null;

        // load security token from file
        using (FileStream stream = File.Open(@"<<token file location>>", FileMode.Open, FileAccess.Read, FileShare.None))
        {
            accessToken = dropBoxStorage.DeserializeSecurityToken(stream);
        }

        // open connection 
        var storageToken = dropBoxStorage.Open(dropBoxConfig, accessToken);


        var publicFolder = dropBoxStorage.GetFolder("/MyFolder"); 

        //upload file
        dropBoxStorage.UploadFile("<<source path>>", publicFolder);


        dropBoxStorage.Close();`

将.NET Framework从4.5更改为4解决了我的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM