private void lvFTPList_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e) { if (lvFTPList.SelectedItems.Count > 0 && !e.Cancel && !string.IsNullOrEmpty(e.DisplayText)) { FtpItem file = (FtpItem)lvFTPList.SelectedItems[0].Tag; if (file.Name != e.DisplayText) { FTPAdapter.Rename(file.FullPath, FTPHelpers.CombineURL(currentDirectory, e.DisplayText)); RefreshDirectory(); } } }
private void lvFTPList_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(string[]))) { Point point = lvFTPList.PointToClient(new Point(e.X, e.Y)); ListViewItem lvi = lvFTPList.GetItemAt(point.X, point.Y); if (lvi != null && e.AllowedEffect == DragDropEffects.Move) { if (tempSelected != null && tempSelected != lvi) { tempSelected.Selected = false; } FtpItem file = lvi.Tag as FtpItem; if (file != null && file.ItemType == FtpItemType.Directory) { string[] filenames = e.Data.GetData(typeof(string[])) as string[]; if (filenames != null) { int renameCount = 0; foreach (string filename in filenames) { if (file.Name != filename) { string path = FTPHelpers.CombineURL(currentDirectory, filename); string movePath = string.Empty; if (file.ItemType == FtpItemType.Unknown) { if (file.Name == ".") { movePath = FTPHelpers.AddSlash(filename, FTPHelpers.SlashType.Prefix, 2); } else if (file.Name == "..") { movePath = FTPHelpers.AddSlash(filename, FTPHelpers.SlashType.Prefix); } } else { movePath = FTPHelpers.CombineURL(file.FullPath, filename); } if (!string.IsNullOrEmpty(movePath)) { FTPAdapter.Rename(path, movePath); renameCount++; } } } if (renameCount > 0) { RefreshDirectory(); } } } } tempSelected = null; } else if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; if (files != null) { FTPAdapter.UploadFiles(files, currentDirectory); RefreshDirectory(); } } }