You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

roman prog 89 level_'s avatar
roman prog 89 level_
Explorer | Level 3
4 years ago

Dropbox API C#

Hello! Tell me please

How to write C # code correctly.

For a complete list of Teams folders and files.
Here is a sample code to get a list of folders for a single Dropbox user.

using (var dbx = new DropboxClient(token))
 {
     var list = await dbx.Files.ListFolderAsync(string.Empty, true);
     foreach (var item in list.Entries.Where(i => i.IsFolder))
           {
                 Console.WriteLine(item.PathDisplay);
           }
 }

 

For a list of Team folders or All Dropbox users. i am trying this method. But the list of folders is not complete.

 

using (var client = new DropboxTeamClient(token))
{
var members = await client.Team.MembersListAsync();
foreach (var member in members.Members.OrderBy(a => a.Profile.Email))
{
var Name = member.Profile.Name.DisplayName;
Console.WriteLine(Name);
var userClient = client.AsMember(member.Profile.TeamMemberId);
var list = await userClient.Files.ListFolderAsync(string.Empty, true);
var x = list.Entries.Where(i => i.IsFolder); //i.IsFolder);
foreach (var item in x) //list.Entries.Where(i => i.IsFolder));
{
Console.WriteLine(item.PathDisplay);
}
}

 

When using code like this. the list of root folders turns out to be correct, but does not show subfolders.

 

using (var dbx = new DropboxClient(token)) 
{

var accountInfo = await dbx.Users.GetCurrentAccountAsync();
Console.WriteLine(accountInfo.RootInfo.RootNamespaceId);
var dbx2 = dbx.WithPathRoot(new Dropbox.Api.Common.PathRoot.Root(accountInfo.RootInfo.RootNamespaceId));
var list = await dbx2.Files.ListFolderAsync(string.Empty, true);
var PathFolder = list.Entries.Where(i => i.IsFolder);

foreach (var item in PathFolder)
{
Console.WriteLine(item.PathDisplay);
}

}

What is the correct code to get a complete list of all folders and subfolders in the Dropbox team?

 

 

 

 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,919 PostsLatest Activity: 10 hours ago
334 Following

If you need more help you can view your support options (expected response time for an email or 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!