Dropbox API Getting a shared link for a file or folder Getting a shared link for a file using the Dropbox .NET library


This example uses the Dropbox .NET library to get a shared link for a file, either by creating a new one, or retrieving an existing one:

SharedLinkMetadata sharedLinkMetadata;
try {
    sharedLinkMetadata = await this.client.Sharing.CreateSharedLinkWithSettingsAsync (path);
} catch (ApiException<CreateSharedLinkWithSettingsError> err) {
    if (err.ErrorResponse.IsSharedLinkAlreadyExists) {
        var sharedLinksMetadata = await this.client.Sharing.ListSharedLinksAsync (path, null, true);
        sharedLinkMetadata = sharedLinksMetadata.Links.First();
    } else {
        throw err;
Console.WriteLine (sharedLinkMetadata.Url);