I'm trying to make a file manager that can bring all files from the directory and subdirectories and list them all in a listView. I have completed everything except the Cut button.
this is my code
private void Cut()
{
CutWasSelected = true;
Clipboard.Clear();
copiedFiles.Clear();
pictureBox1.Image = null;
WinMideaPlayer.URL = null;
if (listView.SelectedItems.Count > 0)
{
foreach (ListViewItem item in listView.SelectedItems)
{
copiedFiles.Add(item.Name);
if (listBothDirAndFiles.Contains(item.Name))
{
listBothDirAndFiles.Remove(item.Name);
}
if (listfiles.Contains(item.Name))
{
listfiles.Remove(item.Name);
}
if (listimages.Contains(item.Name))
{
listimages.Remove(item.Name);
}
if (listvideo.Contains(item.Name))
{
listvideo.Remove(item.Name);
}
if (listWordDocuments.Contains(item.Name))
{
listWordDocuments.Remove(item.Name);
}
if (listPDFdocuments.Contains(item.Name))
{
listPDFdocuments.Remove(item.Name);
}
if (listTxtFiles.Contains(item.Name))
{
listTxtFiles.Remove(item.Name);
}
if (listCompressedFiles.Contains(item.Name))
{
listCompressedFiles.Remove(item.Name);
}
item.Focused = false;
item.Selected = false;
listView.Items.Remove(item);
byte[] moveEffect = new byte[] {2,0,0,0};
MemoryStream dropEffect = new MemoryStream();
dropEffect.Write(moveEffect, 0, moveEffect.Length);
DataObject data = new DataObject();
data.SetFileDropList(copiedFiles);
data.SetData("Preferred DropEffect", dropEffect);
Clipboard.Clear();
Clipboard.SetDataObject(data);
}
}
}
all files are working fine with this code including videos and text files except the images. when I select an Image and press on the cut button and then open the file explorer to paste the image I get a message says that " The action can't be completed because the file is open in TestExplorer4".
I have searched my whole code and I'm pretty sure that I am not using the image anywhere in my project. So, could someone please explain to me why I am getting this message and how can I fix this problem.
thank you in advance.