0

I've setup my first tiny demo app using the Dropbox API and am unable to see any contents of subfolders within the App folder. On the settings tab, I see: Permission type: App folder (this app has read/write access only to files inside its folder).

My folder structure looks like this:

  • /Apps/MyAppFolderName/Folder1/Folder2/File3
  • /Apps/MyAppFolderName/Folder1/File2
  • /Apps/MyAppFolderName/File1

My code looks just like the C# tutorial with no modifications:

async Task ListRootFolder(DropboxClient dbx)
{
    var list = await dbx.Files.ListFolderAsync(string.Empty);

    // show folders then files
    foreach (var item in list.Entries.Where(i => i.IsFolder))
    {
        Console.WriteLine("D  {0}/", item.Name);
    }

    foreach (var item in list.Entries.Where(i => i.IsFile))
    {
        Console.WriteLine("F{0,8} {1}", item.AsFile.Size, item.Name);
    }
}

It only prints out File1 and Folder1; it never gets to File2 nor Folder2 (nor, by extension, File3).

Have I misunderstood the meaning of the App folder permission (in that it doesn't allow access to subfolders) or am I expected to invoke another part of the API to open subfolders? I tried to use the ListFolderContinueAsync(list.Cursor) method after completing the first iteration of list.Entries but it simply returned an empty enumerator.

Jono
  • 1,964
  • 4
  • 18
  • 35

2 Answers2

1

By default, ListFolderAsync won't return subfolders. To get subfolders (and all children), you should use the Recursive parameter on ListFolderAsync, for example:

var list = await dbx.Files.ListFolderAsync(string.Empty, true);

This is preferred over calling ListFolderAsync for each subfolder individually.

In either case though, make sure you check HasMore and call back to ListFolderContinueAsync if necessary, per the ListFolderAsync documentation

Greg
  • 16,359
  • 2
  • 34
  • 44
0

You can access the contents of subfolders if you pass the subfolder name to the ListFolderAsync method:

var list = await dbx.Files.ListFolderAsync(@"/Folder1/Folder2");

The name must be prefixed with '/'.

Jono
  • 1,964
  • 4
  • 18
  • 35