//https://github.com/coryrwest/B2.NET
        public static bool TestB2Cloud(CloudDrive value, out string message)
        {
            bool   result     = false;
            string errMessage = string.Empty;

            try
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    try
                    {
                        // the B2Client will default to the bucketId provided here
                        // for all subsequent calls if you set PersistBucket to true.
                        var options = new B2Net.Models.B2Options()
                        {
                            AccountId      = value.Uid,
                            ApplicationKey = value.Password
                                             //,BucketId = "OPTIONAL BUCKET ID",
                                             //PersistBucket = true / false
                        };

                        var client = new B2Net.B2Client(options);
                        // the returned options object will contain the authorizationToken
                        // necessary for subsequent calls to the B2 API.
                        var canConnect = client.Authorize().Result;

                        //canConnect.
                        //List Buckets
                        //var client = new B2Client(options);
                        //options = client.Authorize().Result;
                        var bucketList   = client.Buckets.GetList().Result;
                        var uploadBasked = bucketList.FirstOrDefault(s => s.BucketName.ToUpper() == value.Location.ToUpper());
                        if (uploadBasked == null)
                        {
                            result     = false;
                            errMessage = "Не найдена корзина на обласном сервисе!";
                        }
                        else
                        {
                            result     = true;
                            errMessage = string.Empty;
                        }
                    }
                    catch (Exception e)
                    {
                        result     = false;
                        errMessage = e.Message;
                    }
                }).GetAwaiter().GetResult();

                message = errMessage;
                return(result);
            }
            catch (Exception e)
            {
                message = e.Message;
                return(false);
            }
        }
        public static bool UploadToB2Cloud(CloudDrive value, string file, out string message)
        {
            bool   result     = false;
            string uploadLink = string.Empty;

            try
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    // the B2Client will default to the bucketId provided here
                    // for all subsequent calls if you set PersistBucket to true.
                    var options = new B2Net.Models.B2Options()
                    {
                        AccountId      = value.Uid,
                        ApplicationKey = value.Password
                                         //,BucketId = "OPTIONAL BUCKET ID",
                                         //PersistBucket = true / false
                    };
                    var client            = new B2Net.B2Client(options);
                    options               = client.Authorize().Result;
                    string uploadFileName = System.IO.Path.GetFileName(file);
                    var bFileData         = File.ReadAllBytes(file);
                    var bucketList        = client.Buckets.GetList().Result;
                    var uploadBasked      = bucketList.FirstOrDefault(s => s.BucketName.ToUpper() == value.Location.ToUpper());
                    try
                    {
                        var fileResult = client.Files.Upload(bFileData, uploadFileName, uploadBasked.BucketId).Result;
                        Console.WriteLine(fileResult.FileId);
                    }
                    catch (Exception uploadErr)
                    {
                        Console.WriteLine(uploadErr);
                        throw;
                    }


                    // { FileId: "",
                    //   FileName: "",
                    //   ContentLength: "",
                    //   ContentSHA1: "",
                    //   ContentType: "",
                    //   FileInfo: Dictionary<string,string> }

                    //var client = pCloud.NET.pCloudClient.CreateClientAsync(value.Uid, value.Password).Result;
                    //CancellationToken cancellationToken = new CancellationToken();
                    //var fileStream = System.IO.File.Open(file, FileMode.Open, FileAccess.Read);
                    //string uploadFileName = System.IO.Path.GetFileName(file);
                    //var folder = client.ListFolderAsync(0).Result;
                    //var res = client.UploadFileAsync(fileStream, 0, uploadFileName, cancellationToken).Result;
                    result = true;
                }).GetAwaiter().GetResult();

                message = string.Empty;
                return(result);
            }
            catch (Exception e)
            {
                message = e.Message;
                return(false);
            }
        }