コード例 #1
0
        public static Task <bool> Move(this MailRuCloud cloud, IStoreItem item, string destinationName)
        {
            if (null == item)
            {
                return(Task.FromResult(false));
            }

            var storeItem = item as MailruStoreItem;

            if (storeItem != null)
            {
                return(cloud.Move(storeItem.FileInfo, destinationName));
            }
            var storeCollection = item as MailruStoreCollection;

            if (storeCollection != null)
            {
                return(cloud.Move(storeCollection.DirectoryInfo, destinationName));
            }

            throw new ArgumentException(string.Empty, nameof(item));
        }
コード例 #2
0
        public void MoveFileFolderTest()
        {
            var api = new MailRuCloud();

            api.Account = this.account;

            var result = api.UploadFileAsync(new FileInfo(@"D:\1.stl"), "/");

            if (result.Result)
            {
                var file = api.GetItems("/").Files.First(x => x.Name == "1.stl");
                api.Move(file, "/Misuc");

                api.CreateFolder("new test folder", "/");
                var folder = api.GetItems("/").Folders.First(x => x.Name == "new test folder");
                api.Move(folder, "/Misuc");

                var entry = api.GetItems("/Misuc");

                Assert.IsNotNull(entry.Folders.FirstOrDefault(x => x.Name == "new test folder"));
                Assert.IsNotNull(entry.Files.FirstOrDefault(x => x.Name == "1.stl"));
            }
        }