You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

melium's avatar
melium
Helpful | Level 6
8 years ago

uploading file to dropbox unauthorized access denied

i get this error

System.UnauthorizedAccessException: Access to the path '/data/data/AndroidMaster.AndroidMaster/files' is denied.

 

public void FileUploadToDropbox()
        {
            string fileSource = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            using (var dbx = new DropboxClient(token"))
            using (var fs = new FileStream(fileSource, FileMode.Create, FileAccess.Read))
            {
                var updated = dbx.Files.UploadAsync(("data.db3"), WriteMode.Overwrite.Instance, body: fs);
            }
        }
  • my working code

    void Upload()
            {
                using (DropboxClient dbx = new DropboxClient("token"))
                {
                    
                    string file = "/data.db3";
                    byte[] byteArray = File.ReadAllBytes(@"/data/data/AndroidMaster.AndroidMaster/files/data.db3");
                    MemoryStream stream1 = new MemoryStream(byteArray);
                    var updated = dbx.Files.UploadAsync(file, WriteMode.Overwrite.Instance, body: stream1);
    
                }
    
            }
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff
    The error message seems to be indicating that your app isn't allow to access the local path (not the remote Dropbox path). That being the case, this seems to be more of an Android issue, so I'm afraid I can't offer much insight. You'll need to look in to why your app can't access that local file path, or if that's not the right path, what is.
    • melium's avatar
      melium
      Helpful | Level 6
      thx for replying man, i got it working. ill post my code here
      • melium's avatar
        melium
        Helpful | Level 6

        my working code

        void Upload()
                {
                    using (DropboxClient dbx = new DropboxClient("token"))
                    {
                        
                        string file = "/data.db3";
                        byte[] byteArray = File.ReadAllBytes(@"/data/data/AndroidMaster.AndroidMaster/files/data.db3");
                        MemoryStream stream1 = new MemoryStream(byteArray);
                        var updated = dbx.Files.UploadAsync(file, WriteMode.Overwrite.Instance, body: stream1);
        
                    }
        
                }

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 3 days ago
333 Following

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 or Facebook.

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!