Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hello everyone!
I'm stuck for 2 days now with the API... I'm creating a game launcher where i need to download(sync), all the files for the game Client from Dropbox to the User.
My goal is to check within the local files if the file from my dropbox account exists, if not, download to the specific folder.
It's kinda frustrating using async tasks... But i need my application to be responsive while checking and downloading files, also using a progressbar showing the specific file that is been downloaded. I don't want to download a Zip file because if i made a small change within the client, i don't want the user to download the whole client again and again...
To check if a file has been modified, i wanted to use the Hashing method, but i have no idea how to use it... So i think it is easier to use the file size as a reference?
After one day i finally did a simple Dropbox files and directory list... It was a pain in the A...
But i noticed it is not possible to async download a file inside the async check? Or am i doing something wrong? I know something about C#, but i had always problems understanding the async function...
So my questions are:
- How can i check if a specific file has been modified in the dropbox directory comparing it with the local files(If it hjas been downloaded before)?
- How can i download the file asynchronously to the same local folder?
- How can i implement a progress bar showing the file name AND the progress in percent(0-100)?
i hope you can help me somehow, i searched for a solution on google before, but i had no luck or i didn't understand the specific solution.
Google Drive is too complicated for me, so i hope i have some luck using Dropbox...
And sorry for my english, i'm no native english speaker!
Oh, yeah, here's my code:
static async Task CheckFiles()
{
using (var dbx = new DropboxClient(token))
{
var amount = 0;
var list = await dbx.Files.ListFolderAsync(string.Empty, true, false, false, false, true);
string directoryPath;
Debug.WriteLine("Dropbox File lister BEGIN");
foreach (var item in list.Entries.Where(i => i.IsFolder))
{
Debug.WriteLine("Directory: " + item.AsFolder.PathDisplay);
directoryPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + ClientDirectory + item.PathDisplay;
Directory.CreateDirectory(directoryPath);
amount++;
}
foreach (var item in list.Entries.Where(i => i.IsFile))
{
Debug.WriteLine("File: {0} | Directory: {1} | Size: {2} | Hash: {3}", item.Name, Path.GetDirectoryName(item.PathDisplay), item.AsFile.Size, item.AsFile.ContentHash);
//That's not working!
using (var response = dbx.Files.DownloadAsync(Path.GetDirectoryName(item.PathDisplay) + "/" + item.Name))
{
Debug.WriteLine(response.GetContentAsStringAsync());
}
//
amount++;
}
Debug.WriteLine("Dropbox File lister END - Found: {0} entries", amount);
}
}
Best regards!
Hi there!
If you need more help you can view your support options (expected response time for a 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!