简体   繁体   English

使用SharpBox上传到Dropbox根目录以外的文件夹

[英]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. 我在使用SharpBox上传到Dropbox中除root以外的任何文件夹时遇到问题。 I can upload using this path var publicFolder = dropBoxStorage.GetFolder("/"); 我可以使用此路径上传var publicFolder = dropBoxStorage.GetFolder("/"); , but not to folder created in root, such as "/MyFolder". ,而不是根目录中创建的文件夹,例如“ / MyFolder”。 I can enumerate files using this path var publicFolder = dropBoxStorage.GetFolder("/MyFolder"); 我可以使用此路径枚举文件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 在Dropbox上创建具有完全Dropbox访问权限的应用
  3. Created console application in C# 用C#创建的控制台应用程序
  4. Installed Sharpbox using NuGet 使用NuGet安装Sharpbox
  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解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Sharpbox API上传到Dropbox - Uploading to Dropbox using Sharpbox API Sharpbox DropBoxTokenIssuer.exe工具无法正常工作,其他工具可以轻松创建Dropbox访问令牌? - Sharpbox DropBoxTokenIssuer.exe tool not working, other tool for easy Dropbox access token creation? 将文件上传到默认OneDrive REST以外的文件夹 - Uploading file to folder other than default OneDrive REST 如何将文件夹浏览器对象的根文件夹更改为系统文件夹以外的特定文件夹/路径? - How do I change the root folder of the Folder Browser object to a specific folder/path other than system folders? 使用Sharpbox 1.2 API登录电子邮件和密码保管箱帐户 - Login email and password dropbox account using sharpbox 1.2 API 递归下载所有内容的文件夹Sharpbox - Download folder with all content recursively, Sharpbox Dropbox文件夹中复制的文件与原始文件名的处理方式有所不同 - Files Copied in the Dropbox folder are treating differently than the original file names 上传文件而不将内容复制到根文件夹 .NET Core 2.2 - Uploading file without copying content to root folder .NET Core 2.2 使用Dropbox Core API在C#中上传文件期间自动创建文件夹 - Create folder automatically during file uploading in C# using Dropbox Core API 上传到 Dropbox 时出错 - Getting an error when uploading to Dropbox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM