cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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: 

ListFolderAsync Does Not Return Newly Added Folders

ListFolderAsync Does Not Return Newly Added Folders

wwaag76
Helpful | Level 6

All I want to do is get a list of subfolders within the Root folder.  However, if I or another member adds a new folder, it does not show up.  Here's the code I'm using.

 

async Task ListRootFolder(DropboxClient dbx)
{
var list = await dbx.Files.ListFolderAsync(string.Empty);
folders.Clear();
foreach (var item in list.Entries.Where(i => i.IsFolder))
{
folders.Add(item.Name);
}

6 Replies 6

Re: ListFolderAsync Does Not Return Newly Added Folders

Greg-DB
Dropboxer

Is the ListFolderResult.HasMore returned by ListFolderAsync set to true? If so, you need to call back to ListFolderContinueAsync to retrieve more results. Please refer to the ListFolderAsync documentation for more information.

Re: ListFolderAsync Does Not Return Newly Added Folders

wwaag76
Helpful | Level 6

Still not working.  Here's my revised code.

 

async Task ListRootFolder(DropboxClient dbx)
{
folders.Clear();
var list = await dbx.Files.ListFolderAsync(string.Empty);
if (list.HasMore)
{
list = await dbx.Files.ListFolderContinueAsync(list.Cursor);
}
foreach (var item in list.Entries.Where(i => i.IsFolder))
{
folders.Add(item.Name);
}
}

 

Re: ListFolderAsync Does Not Return Newly Added Folders

Greg-DB
Dropboxer

You need to check HasMore on each result, including from ListFolderContinueAsync, not just the first one. The number of total pages that will be used is not guaranteed.

 

Also, you should use the contents of each returned page of results. In this latest code it looks like you're only iterating through the contents of the last 'list' returned by ListFolderContinueAsync, but are ignoring the original 'list' returned by ListFolderAsync.

Re: ListFolderAsync Does Not Return Newly Added Folders

wwaag76
Helpful | Level 6

Just to be clear, I'm only talking about a small number of folders.  Here's what's returned in my little app-14 folders.

folders1.png

And here's what in DB--15 folders.

folders2.png

I added "Folder 2" to DB, but that folder is never returned.  I've changed folder names to no avail.

Re: ListFolderAsync Does Not Return Newly Added Folders

Greg-DB
Dropboxer

The page size returned by ListFolderAsync and ListFolderContinueAsync is not guaranteed. Even if there is currently only a relatively small number of folders, the exact number of calls needed may vary, so you need to make sure you're calling back whenever HasMore is true, and checking the contents of each page. 

 

Beyond that, make sure you're connected to the right account and app and are looking in the right place. For instance, if you're using an app with the "app folder" access type, it will only have access to the contents of the special app folder created for the app, by default at "/Apps/<app folder name>", for accounts with the English locale. Make sure you're not accidentally looking at a different copy of the folder, for instance, when comparing with the web site.

Re: ListFolderAsync Does Not Return Newly Added Folders

wwaag76
Helpful | Level 6

Just added a little message box indicating whether HasMore is true.  It returns false, so I'll look for the other things you mentioned.  Thanks for your time.

Who's talking

Top contributors to this post

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