cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We want to hear from you. What do you use Dropbox for?
Close

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: 
Highlighted

how to get all subfolders list from the share section of dropbox?

Explorer | Level 4
 

Hello. Does anyone know how to get all subfolders list from the share section of dropbox?

 

I am using .Net SDK

 

 When I am trying to get a shared folder it gives me by using the below method.

dropbox.Sharing.ListFoldersAsync();

 

but when I need only particular folders subfolders(like all subfolders in XYZ folder) then it's not accepting path as an input parameter,  How can I get a list of subfolders from a folder from share section of dropbox.

 

I am working on a c# app that should browse folders by double-clicking it like our windows folders.

 

var dropbox = new DropboxClient by the way.

 
 
1 Accepted Solution

Accepted Solutions
Highlighted

Re: how to get all subfolders list from the share section of dropbox?

Dropboxer
Dropboxer

I'm not sure I understand the first part of your latest comment. If something isn't working as expected with the Dropbox API with respect to that, please clarify.

 

Anyway, yes, you can check if a given shared folder is mounted in the connected account. Check the SharedFolderMetadata, e.g., as returned in ListFoldersResult.Entries from ListFoldersAsync or ListFoldersContinueAsync. If SharedFolderMetadataBase.PathLower is set, then the folder is mounted. If it is not set, then the folder is not mounted.

View solution in original post

5 Replies 5
Highlighted

Re: how to get all subfolders list from the share section of dropbox?

Dropboxer
Dropboxer

The Sharing.ListFolders methods only let you list shared folders themselves. To list the contents of any arbitrary path, you need to instead use Files.ListFolder and Files.ListFolderContinue methods.

Highlighted

Re: how to get all subfolders list from the share section of dropbox?

Explorer | Level 4

Hi Greg,

 

is Files.ListFolder able to return a list of subfolders of the folders that shared with me but not mount yet?  I was trying it but was giving exception of the path not found, that's why I was using Sharing.ListFolderAsync(),  what am I need to do here  

Highlighted

Re: how to get all subfolders list from the share section of dropbox?

Dropboxer
Dropboxer

Yes, you can technically use these methods to list the contents of an unmounted folder. To do so, you need to use the 'Dropbox-API-Path-Root' header with the "namespace_id" mode, set to the namespace ID of the folder, which you can get from the Sharing.ListFoldersAsync method.

 

In the .NET SDK, that would look like this:

string ACCESS_TOKEN = "...";

string namespaceID = "123456789";

client = new DropboxClient(ACCESS_TOKEN).WithPathRoot(new Dropbox.Api.Common.PathRoot.NamespaceId(namespaceID));

var listResult = await client.Files.ListFolderAsync(string.Empty);
// handle the response, implement ListFolderContinueAsync, and so on

 

Highlighted

Re: how to get all subfolders list from the share section of dropbox?

Explorer | Level 4

Hi Greg,

 

Thanks for your quick response.

 

Yes, it's a working solution, but somehow I am not able to use it because of my flow,

1)I need to Show all shared folder first like a dashboard. that's what I have done using Sharing.ListFoldersAsync().

2) The user should enter any folder nested behavior of folders that can be there,  along with a back button to come back from each. so I achieve this by given the solution above. but the problem is that in my scenario, I need to store back Path in a back button so user can go back after clicking on it. all goes well but what goes wrong when I am on the last but one subfolder from the dashboard and click back button then it is not going to dashboard, it's showing the same folder items. and having some existing code structure limitations here so I used below way to do the same.

 

var mount = await DropboxClient.Sharing.MountFolderAsync(SharedFolderId);
var FolderList= await DropboxClient.Files.ListFolderAsync(path: item.PathLower);

 

It's giving me the expected result that suitable to my existing code scenario,  that I mount a shared folder first then use  DropboxClient.Files.ListFolderAsync(path). but some times facing an issue that "Already mounted" error.  Is there any way to check first that the folder is mounted or not? 

 

 

 

 

   

 

Highlighted

Re: how to get all subfolders list from the share section of dropbox?

Dropboxer
Dropboxer

I'm not sure I understand the first part of your latest comment. If something isn't working as expected with the Dropbox API with respect to that, please clarify.

 

Anyway, yes, you can check if a given shared folder is mounted in the connected account. Check the SharedFolderMetadata, e.g., as returned in ListFoldersResult.Entries from ListFoldersAsync or ListFoldersContinueAsync. If SharedFolderMetadataBase.PathLower is set, then the folder is mounted. If it is not set, then the folder is not mounted.

View solution in original post

Polls
Do you know how to organize your files and folders?
<b>We have created a guide on folder best practice, so you can get organized now <a href="https://www.dropboxforum.com/t5/Business-Tips-tricks/Folder-structure-best-practice/m-p/428456#M39"><u>check it out here</u></a>.</b>

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?