cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

task async convert to void

task async convert to void

melium
Helpful | Level 6
Go to solution

does anyone know a different method not using task async i want to use void

public async Task Download(string remoteFilePath, string localFilePath)
        {
            DropboxClient client2 = new DropboxClient("token");

            remoteFilePath = "img2.jpg";
            localFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            using (var response = await client2.Files.DownloadAsync(remoteFilePath))
            {
                using (var fileStream = File.Create(localFilePath))
                {
                    response.GetContentAsStreamAsync().Result.CopyTo(fileStream);
                }

            }
        }
1 Accepted Solution

Accepted Solutions

melium
Helpful | Level 6
Go to solution

i got it working

public async void DownloadDB()
        {
            try
            {
                DropboxClient client2 = new DropboxClient("token");
                string file = "/data1.db3";
                string folder = @"/data/data/AndroidMaster.AndroidMaster/files/data1.db3";
                using (var response = await client2.Files.DownloadAsync(file))
                {
                    using (var fileStream = File.Create(folder))
                    {
                        (await response.GetContentAsStreamAsync()).CopyTo(fileStream);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution
I'm not sure if I follow your question, but if you're looking for alternate versions of the Dropbox .NET methods, they are also available. E.g., for Download:

https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_BeginDo...
https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_EndDown...

melium
Helpful | Level 6
Go to solution

i got it working

public async void DownloadDB()
        {
            try
            {
                DropboxClient client2 = new DropboxClient("token");
                string file = "/data1.db3";
                string folder = @"/data/data/AndroidMaster.AndroidMaster/files/data1.db3";
                using (var response = await client2.Files.DownloadAsync(file))
                {
                    using (var fileStream = File.Create(folder))
                    {
                        (await response.GetContentAsStreamAsync()).CopyTo(fileStream);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    melium Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?