public static void HandleFolderCreationAndSharing(string folderPath, string emailAddress)
        {
            // GET Dropbox oauth2AccessToken from the Dropbox app you create.
            var dropboxClient = new Dropbox.Api.DropboxClient("");

            FolderMetadata folderData;

            // Try to Get folder
            try
            {
                var folders = dropboxClient.Files.ListFolderAsync(folderPath, true).Result;
                folderData = folders.Entries[0].AsFolder;
            }
            catch
            {
                // Create the folder if not exist
                folderData = dropboxClient.Files.CreateFolderAsync(folderPath).Result;
            }

            string shareId = folderData.SharedFolderId;

            //Initial Share if not sharing enabled on the folder
            //This only shares the folder with the Dropbox owner
            if (folderData.SharedFolderId == null)
            {
                shareId = dropboxClient.Sharing.ShareFolderAsync(folderPath).Result.AsComplete.Value.SharedFolderId;
            }


            MemberSelector.Email mailMember = new MemberSelector.Email(emailAddress);
            AddMember            addMember  = new AddMember(mailMember, AccessLevel.Editor.Instance);

            AddFolderMemberArg args2 = new AddFolderMemberArg(shareId, new List <AddMember>()
            {
                addMember
            }, false, "This is a message sent from the app trial");

            dropboxClient.Sharing.AddFolderMemberAsync(args2).Wait();
        }
        /// <summary>
        /// <para>Begins an asynchronous send to the add folder member route.</para>
        /// </summary>
        /// <param name="sharedFolderId">The ID for the shared folder.</param>
        /// <param name="members">The intended list of members to add.  Added members will
        /// receive invites to join the shared folder.</param>
        /// <param name="quiet">Whether added members should be notified via email and device
        /// notifications of their invite.</param>
        /// <param name="customMessage">Optional message to display to added members in their
        /// invitation.</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="callbackState">A user provided object that distinguished this send
        /// from other send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginAddFolderMember(string sharedFolderId,
                                                     col.IEnumerable<AddMember> members,
                                                     bool quiet = false,
                                                     string customMessage = null,
                                                     sys.AsyncCallback callback = null,
                                                     object callbackState = null)
        {
            var addFolderMemberArg = new AddFolderMemberArg(sharedFolderId,
                                                            members,
                                                            quiet,
                                                            customMessage);

            return this.BeginAddFolderMember(addFolderMemberArg, callback, callbackState);
        }
        /// <summary>
        /// <para>Allows an owner or editor (if the ACL update policy allows) of a shared
        /// folder to add another member.</para>
        /// <para>For the new member to get access to all the functionality for this folder,
        /// you will need to call <see
        /// cref="Dropbox.Api.Sharing.Routes.SharingRoutes.MountFolderAsync" /> on their
        /// behalf.</para>
        /// <para>Warning: This endpoint is in beta and is subject to minor but possibly
        /// backwards-incompatible changes.</para>
        /// </summary>
        /// <param name="sharedFolderId">The ID for the shared folder.</param>
        /// <param name="members">The intended list of members to add.  Added members will
        /// receive invites to join the shared folder.</param>
        /// <param name="quiet">Whether added members should be notified via email and device
        /// notifications of their invite.</param>
        /// <param name="customMessage">Optional message to display to added members in their
        /// invitation.</param>
        /// <returns>The task that represents the asynchronous send operation.</returns>
        /// <exception cref="Dropbox.Api.ApiException{AddFolderMemberError}">Thrown if there is
        /// an error processing the request; This will contain a <see
        /// cref="AddFolderMemberError"/>.</exception>
        public t.Task AddFolderMemberAsync(string sharedFolderId,
                                           col.IEnumerable<AddMember> members,
                                           bool quiet = false,
                                           string customMessage = null)
        {
            var addFolderMemberArg = new AddFolderMemberArg(sharedFolderId,
                                                            members,
                                                            quiet,
                                                            customMessage);

            return this.AddFolderMemberAsync(addFolderMemberArg);
        }
        /// <summary>
        /// <para>Begins an asynchronous send to the add folder member route.</para>
        /// </summary>
        /// <param name="addFolderMemberArg">The request parameters.</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="state">A user provided object that distinguished this send from other
        /// send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginAddFolderMember(AddFolderMemberArg addFolderMemberArg, sys.AsyncCallback callback, object state = null)
        {
            var task = this.AddFolderMemberAsync(addFolderMemberArg);

            return enc.Util.ToApm(task, callback, state);
        }
 /// <summary>
 /// <para>Allows an owner or editor (if the ACL update policy allows) of a shared
 /// folder to add another member.</para>
 /// <para>For the new member to get access to all the functionality for this folder,
 /// you will need to call <see
 /// cref="Dropbox.Api.Sharing.Routes.SharingRoutes.MountFolderAsync" /> on their
 /// behalf.</para>
 /// <para>Warning: This endpoint is in beta and is subject to minor but possibly
 /// backwards-incompatible changes.</para>
 /// </summary>
 /// <param name="addFolderMemberArg">The request parameters</param>
 /// <returns>The task that represents the asynchronous send operation.</returns>
 /// <exception cref="Dropbox.Api.ApiException{AddFolderMemberError}">Thrown if there is
 /// an error processing the request; This will contain a <see
 /// cref="AddFolderMemberError"/>.</exception>
 public t.Task AddFolderMemberAsync(AddFolderMemberArg addFolderMemberArg)
 {
     return this.Transport.SendRpcRequestAsync<AddFolderMemberArg, enc.Empty, AddFolderMemberError>(addFolderMemberArg, "api", "/sharing/add_folder_member", AddFolderMemberArg.Encoder, enc.EmptyDecoder.Instance, AddFolderMemberError.Decoder);
 }