Dropbox API Getting file metadata Handling the error when getting metadata for a non-existing path using the Dropbox .NET library


This example uses the Dropbox .NET library to try to get the metadata for an item at a particular path, and checks for a NotFound error:

try {
    var metadata = await this.client.Files.GetMetadataAsync("/non-existant path");
} catch (Dropbox.Api.ApiException<Dropbox.Api.Files.GetMetadataError> e) {

    if (e.ErrorResponse.IsPath) {
        var pathError = e.ErrorResponse.AsPath.Value;
        if (pathError.IsNotFound) {
            Console.WriteLine ("File or folder not found.");
        } else {
            Console.WriteLine (pathError);
    } else {
        Console.WriteLine (e.ErrorResponse);