Skip to content

Commit 08bb08d

Browse files
author
Stephen Cobbe
committed
Added CreateFolder call to ensure folder existence so SimpleTest does not crash
1 parent 89381a3 commit 08bb08d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Examples/SimpleTest/Program.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ private async Task RunUserTests(DropboxClient client)
8686
await GetCurrentAccount(client);
8787

8888
var path = "/DotNetApi/Help";
89+
var folder = await CreateFolder(client, path);
8990
var list = await ListFolder(client, path);
9091

9192
var firstFile = list.Entries.FirstOrDefault(i => i.IsFile);
@@ -244,10 +245,28 @@ private async Task GetCurrentAccount(DropboxClient client)
244245
}
245246
}
246247

248+
/// <summary>
249+
/// Creates the specified folder.
250+
/// </summary>
251+
/// <remarks>This demonstrates calling an rpc style api in the Files namespace.</remarks>
252+
/// <param name="path">The path of the folder to create.</param>
253+
/// <param name="client">The Dropbox client.</param>
254+
/// <returns>The result from the ListFolderAsync call.</returns>
255+
private async Task<FolderMetadata> CreateFolder(DropboxClient client, string path)
256+
{
257+
Console.WriteLine("--- Creating Folder ---");
258+
var folderArg = new CreateFolderArg(path);
259+
var folder = await client.Files.CreateFolderAsync(folderArg);
260+
261+
Console.WriteLine("Folder: " + path + " created!");
262+
263+
return folder;
264+
}
265+
247266
/// <summary>
248267
/// Lists the items within a folder.
249268
/// </summary>
250-
/// <remarks>This is a demonstrates calling an rpc style api in the Files namespace.</remarks>
269+
/// <remarks>This demonstrates calling an rpc style api in the Files namespace.</remarks>
251270
/// <param name="path">The path to list.</param>
252271
/// <param name="client">The Dropbox client.</param>
253272
/// <returns>The result from the ListFolderAsync call.</returns>

0 commit comments

Comments
 (0)