Start 2025 on time and up to date. Seamlessly integrate your calendars into Dropbox with these simple steps.

Forum Discussion

cristpol95's avatar
cristpol95
Explorer | Level 4
10 months ago

How to ListFolderAsync to a folder in the root folder?

Currently, I am trying to connect a WPF C# app to my Dropbox. I have the folders organized in the way you see in the image. Leaving the string empty opens the "Student" folder, however I want my app to list the contents "code" folder. I have tried using "code", "\\code", "/code" but the app always throws a path not found error.

 

I am not sure what I am doing wrong, any help is appreciated! If you need any more information, please let me know.

 

Thank you!

 

private async Task<List<FolderViewModel>> FetchFoldersAsync(string accessToken)
{
    var items = new List<FolderViewModel>();

    using (var dbx = new DropboxClient(accessToken))
    {
        var list = await dbx.Files.ListFolderAsync("");

        MessageBox.Show(list.Entries.ToString());

        foreach (var item in list.Entries)
        {
             BitmapImage thumbnail = null;

             if (!item.IsFolder)
             {
                  thumbnail = await FetchThumbnailAsync(dbx, item.PathDisplay);
              }

              items.Add(new FolderViewModel
              {
                   Name = item.Name,
                   Thumbnail =
                   thumbnail ?? new BitmapImage(new 
                   Uri("pack://application:,,,/Resources/Images/folder-icon.png", 
                   UriKind.RelativeOrAbsolute)),
               });
          }
     }
     return items;
}
  • By default, API calls to the Dropbox API operate in the "member folder" of the connected account ("Student", in your case), not the "team space". That means that by default, the contents of the team space will not be found.

     

    You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.

  • By default, API calls to the Dropbox API operate in the "member folder" of the connected account ("Student", in your case), not the "team space". That means that by default, the contents of the team space will not be found.

     

    You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.

    • cristpol95's avatar
      cristpol95
      Explorer | Level 4

      Thanks a lot for your response! I applied this to my project, I am now able to connect to the "code" folder.