private async Task UploadDirectoryRecursive(string directoryPath, string path)
        {
            labelAction.Text  = "Uploading...";
            labelContent.Text = path;

            System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(path);
            string brickPath = $"{directoryPath}{directoryInfo.Name}/";

            await BrickExplorer.CreateDirectory(brickPath);

            foreach (System.IO.FileInfo file in directoryInfo.GetFiles())
            {
                if (BrickExplorer.IsRobotFile(file.FullName))
                {
                    labelContent.Text = file.FullName;
                    await BrickExplorer.UploadFile(file.FullName, brickPath, file.Name);
                }
            }

            if (UserSettings.Mode != Mode.BASIC)
            {
                foreach (System.IO.DirectoryInfo subDir in directoryInfo.GetDirectories())
                {
                    await UploadDirectoryRecursive(brickPath, subDir.FullName);
                }
            }
        }
        private async void Execute(object sender, Directory directory, ActionType type)
        {
            switch (type)
            {
            case ActionType.OPEN:
            {
                if (CURRENT_DIRECTORY.Path == directory.Path)
                {
                    return;                                                   // do not open again is already open
                }
                CURRENT_DIRECTORY  = directory;
                SELECTED_DIRECTORY = directory;
                statusBar.SetLoading();
                ((Manager)Parent).UseWaitCursor = true;
                DirectoryContent content = await DirectoryContent.Get(directory);

                previewPane.Set(directory, content.Info);
                directoryContentPane.Set(content);
                statusBar.Set(content.Info);
                navigationBar.Set(directory);
                ((Manager)Parent).UseWaitCursor = false;
                break;
            }

            case ActionType.SELECT:
            {
                SELECTED_DIRECTORY = directory;
                previewPane.Set(directory, null);
                break;
            }

            case ActionType.DOWNLOAD:
            {
                ((Manager)Parent).UseWaitCursor = true;
                await Download(SELECTED_DIRECTORY);

                ((Manager)Parent).UseWaitCursor = false;
                break;
            }

            case ActionType.CREATE_DIRECTORY:
            {
                using (CreateEntryDialog dialog = new CreateEntryDialog(CURRENT_DIRECTORY, EntryType.DIRECTORY, null))
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        string path = System.IO.Path.Combine(CURRENT_DIRECTORY.Path, dialog.EntryName);
                        await BrickExplorer.CreateDirectory(path);

                        await folderTree.Refresh(CURRENT_DIRECTORY);

                        Execute(this, CURRENT_DIRECTORY, ActionType.REFRESH_DIRECTORY);
                    }
                }
                break;
            }

            case ActionType.DELETE:
            {
                if (MessageBox.Show("Are you sure you want to permanently delete this directory and all it's content?", "Delete directory", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    ((Manager)Parent).UseWaitCursor = true;
                    await BrickExplorer.DeleteDirectory(directory.Path, true);

                    await folderTree.Refresh(CURRENT_DIRECTORY);

                    Execute(this, CURRENT_DIRECTORY, ActionType.REFRESH_DIRECTORY);
                    ((Manager)Parent).UseWaitCursor = false;
                }
                break;
            }

            case ActionType.REFRESH_DIRECTORY:
            {
                statusBar.SetLoading();
                ((Manager)Parent).UseWaitCursor = true;
                DirectoryContent content = await DirectoryContent.Get(CURRENT_DIRECTORY);

                directoryContentPane.Set(content);
                previewPane.Set(directory, content.Info);
                statusBar.Set(content.Info);
                ((Manager)Parent).UseWaitCursor = false;
                break;
            }

            case ActionType.UPLOAD_DIRECTORY:
            {
                await UploadDirectory();

                await folderTree.Refresh(CURRENT_DIRECTORY);

                Execute(this, CURRENT_DIRECTORY, ActionType.REFRESH_DIRECTORY);
                break;
            }
            }
        }