Delete folder in Box API C#

in this article, we will see how to delete folder from box storage using box api c#.

1. First you need clienti id and client secret

2. Next authorize box to get access and refresh token.

3. Then find the target folder to delete and use the below code to delete.

        public async Task<BoxResult> BOXAPIDeleteFolder(string folderid, BoxClientSettings BoxClientSettings, bool isrecursive = true)
            BoxResult objBoxResult = new BoxResult();            
                var config = new BoxConfig(BoxClientSettings.boxClientId, BoxClientSettings.boxClientSecret, new Uri(BoxClientSettings.boxRedirectUrl));
                var session = new OAuthSession(BoxClientSettings.boxAccessToken, BoxClientSettings.boxRefreshToken, 3600, "bearer");
                var client = new BoxClient(config, session);
                bool delete_folder = await client.FoldersManager.DeleteAsync(folderid, isrecursive);

                if (delete_folder)
                    objBoxResult.boxStatusMessage = BOXSTATUSCODES.SUCCESS.ToString();
                    objBoxResult.boxStatusMessage = BOXSTATUSCODES.ERROR.ToString();

            catch (Exception ex)
                objBoxResult.boxStatusMessage = ex.Message;
            return objBoxResult;


Labels: BOX API C#, box api, box sdk, box c# api, delete folder box api c#


Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker