Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:29:32+00:00 2026-06-16T04:29:32+00:00

I am currently working on a c# project and I am trying to implement

  • 0

I am currently working on a c# project and I am trying to implement dropbox within my program. I have successfully managed to authenticate dropbox and create a directory but I can’t work out how to upload a file.

The Dropbox access type is AppFolder and I can create a folder within the app folder. To upload the file, just for a test, I am writing something to a text field and submitting the form, I then write the string to a text file, within the working directory of the executable and I am then trying to upload the file into the root of the app folder, but it is throwing an exception one more errors have occurred probably the least useful error.

In case it matters below is how I am authenticating Dropbox.

private void authenticateDropbox(Boolean isFromCallBack = false)
        {
            try
            {
                if (!isFromCallBack)
                {
                    dropboxServiceProvider = new DropboxServiceProvider(dropboxAppKey, dropboxAppSecret, AccessLevel.AppFolder);
                    //lblStatus.Content = "Getting request Token";

                    oauthToken = dropboxServiceProvider.OAuthOperations.FetchRequestTokenAsync(callbackUrl, null).Result;
                    //lblStatus.Content = "Request token retrieved";

                    parameters = new OAuth1Parameters();
                    parameters.CallbackUrl = callbackUrl;
                    string authenticateUrl = dropboxServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, parameters);
                    webDropbox.Navigate(new Uri(authenticateUrl));
                }
                else
                {
                    AuthorizedRequestToken requestToken = new AuthorizedRequestToken(oauthToken, null);
                    OAuthToken oauthAccessToken = dropboxServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;

                    Properties.Settings.Default.dropbox_accessSecret = oauthAccessToken.Secret;
                    Properties.Settings.Default.dropbox_accessToken = oauthAccessToken.Value;
                    Properties.Settings.Default.Save();

                    IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

                    DropboxProfile profile = dropbox.GetUserProfileAsync().Result;
                    Close();
                    MessageBox.Show("Welcome " + profile.DisplayName, "DropBox Success", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (AggregateException ex)
            {
                MessageBox.Show("AggregateException: Failed to authenticate\n\n" + ex.Message, "Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("General Exception: Failed to authenticate\n\n" + ex.Message, "Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        private void webDropbox_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e)
        {
            string url = e.Uri.ToString();
            if (url.StartsWith(callbackUrl, StringComparison.OrdinalIgnoreCase))
            {
                authenticateDropbox(true);
            }
        }

Below is the code on how I am creating the directory, which is working, then upload a file

private void uploadContentToDropbox()
        {
            try
            {
                DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(dropboxAppKey, dropboxAppSecret, AccessLevel.AppFolder);
                IDropbox dropbox = dropboxServiceProvider.GetApi(Properties.Settings.Default.dropbox_accessToken, Properties.Settings.Default.dropbox_accessSecret);

                //DeltaPage deltaPage = dropbox.DeltaAsync(null).Result;
                writeContentToFile();

                Entry createFolderEntry = dropbox.CreateFolderAsync("Test Folder").Result;

                Entry uploadFileEntry = dropbox.UploadFileAsync(
                    new AssemblyResource("assembly://DropBoxTest/DropBoxTest/upload.txt"), "upload.txt", true, null, CancellationToken.None).Result;
            }
            catch (AggregateException ex)
            {
                MessageBox.Show("Failed to upload:\n\n" + ex.Message, "Dropbox Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("General failed to upload:\n\n" + ex.Message, "Dropbox Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

I’m not sure if the uploadFileEntry is the one that I want as I don’t see why I need to say new AssemblyResource as its not a resource of the program it is just a text file that is created.

Thanks for any help you can provide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:29:33+00:00Added an answer on June 16, 2026 at 4:29 am

    I’ve managed to find out what to do after hours of trawling through Google, managed to get some luck to find something.

    It doesn’t need to be an assembly resource, so I instead create the file as I was before but before doing the upload I do the following:

    var res = new FileResource("upload.txt");
    

    And then change the upload to the following:

    Entry uploadFileEntry = dropbox.UploadFileAsync(
                        res, "upload.txt", true, null, CancellationToken.None).Result;
    

    Notice, I’m not doing new AssemblyResource anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a ASP.Net 3.5 project and trying to implement session timeout
I'm currently working on a little project in which I'm trying to create a
I am currently working on an android project and I am trying to create
im trying to implement a search for a project I'm currently working on. problem
I am currently working on a project, and I am trying to implement Protocol
I'm not currently working on a coding project that is trying to implement this,
Currently, I'm trying to get the lib working in my project, but with no
I'm currently working on a project using netbeans 6.9 and grails 1.3. I'm trying
Heya, I'm currently trying to get bltoolkit working in my project. I've added the
So I'm working on my first big C# project and am currently trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.