/// <summary> /// 삭제 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonDeleteSelect_Click(object sender, EventArgs e) { int i = 0; ListView.SelectedListViewItemCollection selectedItems = ListViewFileList.SelectedItems; ListView.SelectedIndexCollection items = ListViewFileList.SelectedIndices; while (items.Count > 0) { string remove = selectedItems[i].SubItems[1].Text + @"\" + selectedItems[i].Text; FileInfo removeFile = new FileInfo(remove); if (removeFile.Exists) { removeFile.Delete(); } ListViewFileList.Items[i].Remove(); } ListViewFileList.Refresh(); }
/// <summary> /// 일괄 이동 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonMove_Click(object sender, EventArgs e) { int i = 0; FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.ShowDialog(); movePath = dialog.SelectedPath; ListView.SelectedListViewItemCollection selectedItems = ListViewFileList.SelectedItems; ListView.SelectedIndexCollection items = ListViewFileList.SelectedIndices; while (i < items.Count && movePath.Equals("") == false) { string move = selectedItems[i].SubItems[2].Text + @"\" + selectedItems[i].SubItems[1].Text; FileInfo moveFile = new FileInfo(move); if (moveFile.Exists) { try { moveFile.MoveTo(movePath + @"\" + selectedItems[i].SubItems[1].Text); ListViewFileList.Items[i].SubItems[2].Text = movePath; } catch { // 중복 시, 상위 폴더 명을 접합 string tmp = CreateAdditionalString(selectedItems[i].SubItems[2].Text); moveFile.MoveTo(movePath + @"\" + tmp + selectedItems[i].SubItems[1].Text); ListViewFileList.Items[i].SubItems[1].Text = tmp + selectedItems[i].SubItems[1].Text; ListViewFileList.Items[i].SubItems[2].Text = movePath; } finally { if (movePath.Contains(MainForm.pTextPath.Text) == false) { ListViewFileList.Items[i].Remove(); ListViewFileList.Refresh(); } } } i++; } }