/// <summary> /// 文件列表编辑完成事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listView_File_EditSubItemCompleted(object sender, ListViewPlus.EditSubItemEventArgs e) { switch (e.UserSate) { case "rename": ((ListView)sender).Items[e.ItemRowIndex].Name = e.Label; //发送重命名请求 //oldFileName,newFileName //为了安全起见,这里使用绝对路径 _selectDirInTree = GetSelectedDirPathInDirTree(); string oldFileName = e.OldLabel; string newFileName = e.Label; string oldFileNameFullPath = Path.Combine(_selectDirInTree, oldFileName); string newFileNameFullPath = Path.Combine(_selectDirInTree, newFileName); _fileManager.RenameFileOrDir(oldFileNameFullPath, newFileNameFullPath); break; case "modifyTime": SelectedItemsStatus status = (SelectedItemsStatus)(((ListView)sender).Items[e.ItemRowIndex]).Tag; if (status == SelectedItemsStatus.IsDir) { string file = GetSelectedPathInListView(true); //修改时间 _fileManager.ModifyFileOrDirTime(file, e.Label); } else if (status == SelectedItemsStatus.IsFile) { string file = GetSelectedPathInListView(false); //修改时间 _fileManager.ModifyFileOrDirTime(file, e.Label); } break; case "createDir": ////打开设置界面 _selectDirInTree = GetSelectedDirPathInDirTree(); string dirName = e.Label; string dirFullPath = Path.Combine(_selectDirInTree, dirName); _fileManager.CreateDir(dirFullPath); break; default: break; } }
/// <summary> /// 文件列表编辑完成事件 /// </summary> private void listView_File_EditSubItemCompleted(object sender, ListViewPlus.EditSubItemEventArgs e) { string currentDir = string.Empty; switch (e.UserSate) { case "rename": ((ListView)sender).Items[e.ItemRowIndex].Name = e.Label; //发送重命名请求 //oldFileName,newFileName //为了安全起见,这里使用绝对路径 currentDir = GetCurrentDirPath(); string oldFileName = e.OldLabel; string newFileName = e.Label; string oldFileNameFullPath = Path.Combine(currentDir, oldFileName); string newFileNameFullPath = Path.Combine(currentDir, newFileName); _fileManager.RenameFileOrDir(oldFileNameFullPath, newFileNameFullPath); break; case "modifyTime": FileInfo fileInfo = (FileInfo)(((ListView)sender).Items[e.ItemRowIndex]).Tag; //修改时间 _fileManager.ModifyFileOrDirTime(fileInfo.FullName, e.Label); break; case "createDir": ////打开设置界面 currentDir = GetCurrentDirPath(); string dirName = e.Label; string dirFullPath = Path.Combine(currentDir, dirName); _fileManager.CreateDir(dirFullPath); break; default: break; } }