public async Task RenameEntity(string path, string newName) { path = Equals(path[0], '/') ? path : "/" + path; var entity = new DriveEntityInfo(path, this); await MoveEntity(path, entity.Parent, newName); }
public void Show(DriveEntityInfo item, Point location) { this.item = item; newNameBox.Text = Path.GetFileNameWithoutExtension(item.Name); Items.Remove(newNameBox); Show(location); }
public async Task Upload(string pathToEntity, string pathToCatalogForSave = "") { var entity = new DriveEntityInfo(pathToEntity, this); var data = ReadEntity(entity.FullPath); await diskApi.Files.UploadAsync( $"{pathToCatalogForSave}/{entity.Name}", WriteMode.Overwrite.Instance, body : data); }
public async Task Save(string pathToEntity, string pathToCatalogForSave) { var data = await Download(pathToEntity); var entity = new DriveEntityInfo(pathToEntity, this); var path = entity.IsDirectory ? $"{pathToCatalogForSave}/{entity.Name}.zip" : $"{pathToCatalogForSave}/{entity.Name}"; await File.WriteAllBytesAsync(path, data); }
public async Task <byte[]> Download(string pathToEntity) { var entity = new DriveEntityInfo(pathToEntity, this); if (entity.IsDirectory) { return(await(await diskApi.Files.DownloadZipAsync(entity.FullPath)).GetContentAsByteArrayAsync()); } return(await(await diskApi.Files.DownloadAsync(entity.FullPath)).GetContentAsByteArrayAsync()); }
public async Task Upload(string pathToEntity, string pathToCatalogForSave = "") { var entity = new DriveEntityInfo(pathToEntity, this); var pathForSave = $"{pathToCatalogForSave}/{entity.Name}"; await diskApi.Files.UploadFileAsync( pathForSave, false, pathToEntity, CancellationToken.None); }
private async Task MoveEntity(string pathToEntity, string whereToMove, string newName = "") { var entity = new DriveEntityInfo(pathToEntity, this); var path = newName.Equals("") ? $"{whereToMove}/{entity.Name}" : $"{whereToMove}/{newName}"; await diskApi.Commands.MoveAsync(new MoveFileRequest { From = pathToEntity, Overwrite = false, Path = path }); }
private async Task MoveEntity(string pathToEntity, string whereToMove, string newName = "") { var entity = new DriveEntityInfo(pathToEntity, this); var toPath = newName.Equals("") ? $"{whereToMove}/{entity.Name}" : $"{whereToMove}/{newName}"; try { await diskApi.Files.MoveV2Async(pathToEntity, toPath); } catch (ApiException <RelocationError> e) { Console.WriteLine(e.Message); } }
private void AddFolderBtn(DriveEntityInfo driveEntity, string driveName) { var directoryBtn = new Button() { FlatAppearance = { BorderSize = 0, MouseDownBackColor = System.Drawing.Color.FromArgb( ((int)(((byte)(173)))), ((int)(((byte)(20)))), ((int)(((byte)(0))))) }, FlatStyle = System.Windows.Forms.FlatStyle.Flat, ForeColor = System.Drawing.SystemColors.ButtonHighlight, Size = new System.Drawing.Size(98, 34), Name = "directoryBtn", TabIndex = 1, Text = driveEntity.Name.Equals("") ? driveName + " >" : driveEntity.Name + " >", Tag = driveEntity, AutoSize = true, UseVisualStyleBackColor = true }; directoryBtn.Click += DirectoryBtn_Click; folderPanels[driveEntity.DriveEngine].Controls.Add(directoryBtn); }
public async Task RenameEntity(string path, string newName) { var entity = new DriveEntityInfo(path, this); await MoveEntity(path, entity.Parent, newName); }
public async Task Save(string pathToEntity, string pathToCatalogForSave) { var entity = new DriveEntityInfo(pathToEntity, this); await diskApi.Files.DownloadFileAsync(path : entity.FullPath, Path.Combine(pathToCatalogForSave, entity.IsDirectory ? entity.Name + ".zip" : entity.Name)); }