/// <summary> /// Сохранить в файл в облаке список ссылок /// </summary> public void Save() { lock (_lockContainer) { Logger.Info($"Saving links to {LinkContainerName}"); string content = JsonConvert.SerializeObject(_itemList, Formatting.Indented); string path = WebDavPath.Combine(WebDavPath.Root, LinkContainerName); try { _cloud.FileUploaded -= OnFileUploaded; _cloud.UploadFile(path, content); } finally { _cloud.FileUploaded += OnFileUploaded; } } }
static void Main(string[] args) { Console.WriteLine(args.Length.ToString()); if (args.Length != 4) { return; } var fileName = args[0]; var destinationPath = args[1]; var login = args[2]; var password = args[3]; account = new Account(login, password); var api = new MailRuCloud() { Account = account }; //var percent = 0; api.ChangingProgressEvent += delegate(object sender, ProgressChangedEventArgs e) { //percent = e.ProgressPercentage Console.WriteLine("uploading " + e.ProgressPercentage); }; api.UploadFile(new FileInfo(fileName), destinationPath).Wait(); DateTime today = DateTime.Now; DateTime answer = today.AddDays(Convert.ToDouble(-45)); Entry items = api.GetItems(destinationPath).Result; foreach (MailRuCloudApi.File f in items.Files) { if (f.LastModifiedTimeUTC < answer) { api.Remove(f.FulPath).Wait(); } } api = null; }
public void UploadFileTest() { var api = new MailRuCloud(); api.Account = this.account; var percent = 0; api.ChangingProgressEvent += delegate(object sender, ProgressChangedEventArgs e) { percent = e.ProgressPercentage; }; var task = api.UploadFile(new FileInfo(@"..\..\Properties\AssemblyInfo.cs"), "/"); Assert.IsTrue(task.Result); Assert.IsTrue(percent == 100); Thread.Sleep(5000); }