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

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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");
    Console.WriteLine(metadata.Name);
} 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);
    }
}


Got any Dropbox API Question?