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 Ross uses Dropbox to answer some new house questions 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: 

Dropbox API C#

Dropbox API C#

roman svetofor
Explorer | Level 3
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?

 

 

 

 

1 Accepted Solution

Accepted Solutions

Re: Dropbox API C#

Greg-DB
Dropboxer

The ListFolder interface is paginated, and so you aren't guaranteed to get everything returned in one call like this. You'll need to also implement the ListFolderContinueAsync method. Please refer to the ListFolderAsync documentation for more information.

 

I also recommend reading the File Access Guide and Team Files Guide.

View solution in original post

1 Reply 1

Re: Dropbox API C#

Greg-DB
Dropboxer

The ListFolder interface is paginated, and so you aren't guaranteed to get everything returned in one call like this. You'll need to also implement the ListFolderContinueAsync method. Please refer to the ListFolderAsync documentation for more information.

 

I also recommend reading the File Access Guide and Team Files Guide.

View solution in original post

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?