cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

How to correctly create a task

How to correctly create a task

Nenciu D.
New member | Level 1

I'm trying to create folder and then to store the metadata of create folder:

  try
{
FolderMetadata folderMetadata = client.Files.CreateFolderAsync(newFolderPath).Result;
}
catch (Exception e)
{
string m = e.Message;
}

 

And it crashes without any exception. 

This method is working for oneDrive : LiveOperationResult meResult = liveConnectClient.GetAsync("me").Result; //this gets info about the client and is also an awaitable task

 

So what's the best way to create a folder?

This one?

async Task CreateFolder(string folderName)
{
   var response = await dbx.Files.CreateFolderAsync(folderName);
  
}
 
And then to call:
  System.Threading.Tasks.Task taskCreateFolder = Task.Run(() => CreateFolder(cloudPath));
taskCreateFolder.Wait();
 
Thanks
 
3 Replies 3

Greg-DB
Dropbox Staff

Your code looks fine. What do you mean by "it crashes without any exception"? That shouldn't be possible. It looks like you're storing the exception message but not reading it (string m = e.Message). 

I recommend adding a breakpoint there to see what the actual API exception is. For example, it's possible newFolderPath is invalid.

Nenciu D.
New member | Level 1

Hi Gregory,

Thanks for all your answers.

I'm trying to get the result of a task using the following:

try

{

 ListFolderResult allItems = dbxClient.Files.EndListFolder(dbxClient.Files.ListFolderAsync(string.Empty, true));

}

catch(ApiException<ListFolderContinueError> err)

{

string message = err.Message;

}

And not getting any error message.

Greg-DB
Dropbox Staff

So you're saying the code execution doesn't enter the catch block, which should mean the method succeeded? In that case, from your code, it looks like allItems should then be defined containing the information. What do you do with allItems after this code runs?

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Nenciu D. New member | Level 1
What do Dropbox user levels mean?