@@ -9,6 +9,7 @@ namespace SimpleTest
99 using System . Threading . Tasks ;
1010
1111 using Dropbox . Api ;
12+ using Dropbox . Api . Common ;
1213 using Dropbox . Api . Files ;
1314 using Dropbox . Api . Team ;
1415
@@ -118,6 +119,9 @@ private async Task RunUserTests(DropboxClient client)
118119 await Download ( client , path , firstFile . AsFile ) ;
119120 }
120121
122+ var pathInTeamSpace = "/Test" ;
123+ await ListFolderInTeamSpace ( client , pathInTeamSpace ) ;
124+
121125 await Upload ( client , path , "Test.txt" , "This is a text file" ) ;
122126
123127 await ChunkUpload ( client , path , "Binary" ) ;
@@ -313,11 +317,45 @@ private async Task<FolderMetadata> CreateFolder(DropboxClient client, string pat
313317 {
314318 Console . WriteLine ( "--- Creating Folder ---" ) ;
315319 var folderArg = new CreateFolderArg ( path ) ;
316- var folder = await client . Files . CreateFolderAsync ( folderArg ) ;
320+ var folder = await client . Files . CreateFolderV2Async ( folderArg ) ;
317321
318322 Console . WriteLine ( "Folder: " + path + " created!" ) ;
319323
320- return folder ;
324+ return folder . Metadata ;
325+ }
326+
327+ /// <summary>
328+ /// Lists the items within a folder inside team space. See
329+ /// https://www.dropbox.com/developers/reference/namespace-guide for details about
330+ /// user namespace vs team namespace.
331+ /// </summary>
332+ /// <param name="client">The Dropbox client.</param>
333+ /// <param name="path">The path to list.</param>
334+ /// <returns>The <see cref="Task"/></returns>
335+ private async Task ListFolderInTeamSpace ( DropboxClient client , string path )
336+ {
337+ // Fetch root namespace info from user's account info.
338+ var account = await client . Users . GetCurrentAccountAsync ( ) ;
339+
340+ if ( ! account . RootInfo . IsTeam )
341+ {
342+ Console . WriteLine ( "This user doesn't belong to a team with shared space." ) ;
343+ }
344+ else
345+ {
346+ try
347+ {
348+ // Point path root to namespace id of team space.
349+ client = client . WithPathRoot ( new PathRoot . Root ( account . RootInfo . RootNamespaceId ) ) ;
350+ await ListFolder ( client , path ) ;
351+ }
352+ catch ( PathRootException ex )
353+ {
354+ Console . WriteLine (
355+ "The user's root namespace ID has changed to {0}" ,
356+ ex . ErrorResponse . AsInvalidRoot . Value ) ;
357+ }
358+ }
321359 }
322360
323361 /// <summary>
0 commit comments