I am making a file transfer application (server-client).
I have two lists for exploring the local PC and the remote PC. before sending / receiving items.
I need to check if another file or folder has the same name on the destination path. when I click on the [send or receive] button, the item is added to the list .. then when I click on the [Start transfer] button .. it starts.
so the AddItems method is called when I click the Receive or Send button .. I get SelectedItems from the source ListView .. and the destination ListView Elements ... then I check each element in SelectedItems if it exists in Elements

I tried to use
items.Contain(item)
but it didn’t work, it always gave me a lie, even if the element already exists.
so I used items.ContainKey and it worked. But in case I have a file named "Temp" without an extension and a folder in the destination path, also called "Temp" .. it will return True .. and this is my problem ..
bool YesToAll = false; public void AddItems(ListView.SelectedListViewItemCollection selectedItems, ListView.ListViewItemCollection items,TransferType type,string destPath) { foreach(ListViewItem item in selectedItems) { if (items.ContainsKey(item.Name) && !YesToAll) { MyMessageBox msgbox = new MyMessageBox("Item is already exists .. Do you want to replace (" + item.Text + ") ?"); msgbox.ShowDialog(); if (msgbox.DialogResult == DialogResult.Yes) { Add(item, type, destPath); } else if (msgbox.DialogResult == DialogResult.OK) { YesToAll = true; Add(item, type, destPath); } else if (msgbox.DialogResult == DialogResult.No) { continue; } else { return; } } else { Add(item, type, destPath); } } YesToAll = false; } private void Add(ListViewItem item,TransferType type,string path) { ListViewItem newItem = (ListViewItem)item.Clone(); newItem.ImageIndex = imageList1.Images.Add(item.ImageList.Images[item.ImageIndex],Color.Transparent); newItem.SubItems.Add(type.ToString()); newItem.SubItems.Add(path); newItem.Tag = type; listView1.Items.Add(newItem); }
YesToAll is true when the user clicked the [Yes for All] button in the confirmation dialog box.
TransferType - it's just to mark an element if it will use SendMethod or ReceiveMethod
public enum TransferType { Send , Receive };
so how can i fix this. Should I use my own method instead of [Contains], which checks the name and type (file or folder), because each item already has a subItem that indicates whether it is a folder or file
early.