public static void DeleteFile(CloudData data)
        {
            var data_original = GetFile("CloudInfo.bson");

            BackupFile("CloudInfo_predelete.bson", data_original);
            var cloud_data = ParseBson <Dictionary <string, CloudData> >(data_original);
            KeyValuePair <string, CloudData>?found = null;

            foreach (var kv in cloud_data)
            {
                if (kv.Value.Folder == data.Folder &&
                    kv.Value.Name == data.Name &&
                    kv.Value.URL == data.URL)
                {
                    found = kv;
                    break;
                }
            }
            if (found == null)
            {
                throw new Exception("Could not find file " + data.Name + ". Please, refresh the tree.");
            }
            cloud_data.Remove(found.Value.Key);
            var new_data = ToBson(cloud_data);

            BackupFile("CloudInfo_postdelete.bson", new_data);
            UploadFile("CloudInfo.bson", new_data);
        }
        public static async Task <bool> UploadFiles(string folderpath, string[] filenames, IProgress <double> progress)
        {
            var data_original = GetFile("CloudInfo.bson");

            BackupFile("CloudInfo_preupload.bson", data_original);
            var cloud_data = ParseBson <Dictionary <string, CloudData> >(data_original);

            progress.Report(0.1);
            int nfiles          = filenames.Length;
            int files_processed = 0;

            foreach (var name in filenames)
            {
                var file_data  = File.ReadAllBytes(name);
                var file_name  = Path.GetFileName(name);
                var file_hash  = BitConverter.ToString(new SHA1CryptoServiceProvider().ComputeHash(file_data)).Replace("-", "");
                var cloud_name = file_hash + "_" + file_name;

                var file_url = await UploadFileAndShare(cloud_name, file_hash, file_data);

                var cloudfile_data = new CloudData(file_name, file_url, file_data.Length, DateTime.Now.ToString(), folderpath);
                cloud_data[cloud_name] = cloudfile_data;

                files_processed++;
                progress.Report(0.1 + 0.9 * files_processed / nfiles);
            }
            var new_data = ToBson(cloud_data);

            BackupFile("CloudInfo_postload.bson", new_data);
            UploadFile("CloudInfo.bson", new_data);
            return(true);
        }