private void UploadDirectory(StorageEngine storageEngine, Site binderSite, string subDirectoryName, string directorySource, string directoryDestination)
        {
            try
            {
                Console.WriteLine("Uploading directory " + directorySource + "/" + subDirectoryName);

                var directoryDestinationModel =
                    new GetFolderOperation(binderSite, directoryDestination, AuthorisedSession).ResponseMessage
                    .Content <SiteFolderModel>();

                if (directoryDestinationModel.Folders.All(folder => folder.Name.ToLower() != subDirectoryName.ToLower()))
                {
                    Console.WriteLine("Creating folder " + subDirectoryName);
                    var createFolderOperation = new CreateFolderOperation(binderSite, directoryDestination,
                                                                          AuthorisedSession, subDirectoryName);

                    if (!createFolderOperation.ResponseMessage.IsSuccessStatusCode)
                    {
                        throw new ApplicationException("Could not create folder " + subDirectoryName + " - " + createFolderOperation.ResponseMessage.StatusCode);
                    }
                }


                string newSource      = Path.Combine(directorySource, subDirectoryName);
                string newDestination = directoryDestination.TrimEnd('/') + "/" + subDirectoryName;


                var files = Directory.GetFiles(newSource, "*.*");
                Console.WriteLine(files.Length + " files");

                UploadFiles(files, binderSite, storageEngine, newDestination);
                foreach (var newDirectory in Directory.GetDirectories(newSource))
                {
                    string newDirectoryName = new DirectoryInfo(newDirectory).Name;
                    UploadDirectory(storageEngine, binderSite, newDirectoryName, newSource, newDestination);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: Could not upload directory " + subDirectoryName + " - " + ex.Message);
            }
        }
        private void UploadDirectory(StorageEngine storageEngine, Site binderSite, string subDirectoryName, string directorySource, string directoryDestination)
        {

            try
            {


                Console.WriteLine("Uploading directory " + directorySource + "/" + subDirectoryName);

                var directoryDestinationModel =
                    new GetFolderOperation(binderSite, directoryDestination, AuthorisedSession).ResponseMessage
                        .Content<SiteFolderModel>();

                if (directoryDestinationModel.Folders.All(folder => folder.Name.ToLower() != subDirectoryName.ToLower()))
                {
                    Console.WriteLine("Creating folder " + subDirectoryName);
                    var createFolderOperation = new CreateFolderOperation(binderSite, directoryDestination,
                        AuthorisedSession, subDirectoryName);

                    if (!createFolderOperation.ResponseMessage.IsSuccessStatusCode)
                    {
                        throw new ApplicationException("Could not create folder " + subDirectoryName + " - " + createFolderOperation.ResponseMessage.StatusCode);
                    }

                }


                string newSource = Path.Combine(directorySource, subDirectoryName);
                string newDestination = directoryDestination.TrimEnd('/') + "/" + subDirectoryName;


                var files = Directory.GetFiles(newSource, "*.*");
                Console.WriteLine(files.Length + " files");

                UploadFiles(files, binderSite, storageEngine, newDestination);
                foreach (var newDirectory in Directory.GetDirectories(newSource))
                {
                    string newDirectoryName = new DirectoryInfo(newDirectory).Name;
                    UploadDirectory(storageEngine, binderSite, newDirectoryName, newSource, newDestination);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: Could not upload directory " + subDirectoryName + " - " + ex.Message);
            }


        }