cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We recently received a question asking for advice on how to set up a Dropbox account for an elderly family member. This prompted us to think about the different ways we can make Dropbox more accessible in general, learn about it and add your tips right over here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
1
Ask
2
Comments

uploading file to dropbox unauthorized access denied

uploading file to dropbox unauthorized access denied

melium
Helpful | Level 6

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);
            }
        }
1 Accepted Solution

Accepted Solutions

Re: uploading file to dropbox unauthorized access denied

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);

            }

        }

View solution in original post

3 Replies 3

Re: uploading file to dropbox unauthorized access denied

Greg-DB
Dropboxer
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.

Re: uploading file to dropbox unauthorized access denied

melium
Helpful | Level 6
thx for replying man, i got it working. ill post my code here

Re: uploading file to dropbox unauthorized access denied

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);

            }

        }
Who's talking

Top contributors to this post

  • User avatar
    melium Helpful | Level 6
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?