Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:28:20+00:00 2026-05-31T07:28:20+00:00

i making a file transfer (server-client) application .. i have two listviewS to explore

  • 0

i making a file transfer (server-client) application ..
i have two listviewS to explore Local PC and Remote PC .. before send/receive the items..
i need to check if there’s another file or folder has the same name at the destination path..
when i press on the button [send or receive] the item added to a list.. then when i press on button [Start Transfer] .. it starts.

so the AddItems Method called when i press the button Receive or Send .. i get the SelectedItems from the source ListView .. and the Items of the destination ListView … then i check for each item in SelectedItems if it is exists in Items

enter image description here

i tried to use

items.Contain(item)

but it didn’t work it always gave me false even if the item is already exists.

so i used items.ContainKey and it worked .. but in case that i have a file named “Temp” with no extension and a folder in destination path also named “Temp” .. it will returns True .. and that’s 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 set to true when the user clicked on [Yes to all] button in the confirm dialogbox.
TransferType is just to mark the item if it’s going to use SendMethod or ReceiveMethod

public enum TransferType
    {
        Send , Receive
    };

so how do i fix that .. should i use a custom method instead of [Contains] that checks for the name and for the type (file or folder) because each item is already has a subItem which tell if it is a folder or a file

thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:28:21+00:00Added an answer on May 31, 2026 at 7:28 am

    Please try this

    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)
                {   
                    ListViewItem lvtemp=items.Find(item.Name)[0];
    if((lvTemp.SubItems[0].Text!= "[Folder]" && item.SubItem[0].Text!="[Folder]" ) or (lvTemp.SubItems[0].Text== item.SubItems[0].Text && lvTemp.SubItems[0].Text="[Folder]") )
    {
                    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);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a file transfer application between (client-server) and have the tools I need
im making a Server-Client application.. chat sends commands file-transfer i was wondering if it
Im making a file manager (Server-Client application) so i can mess with remote computer
I am making a protocol, client and server which provide file transfer functionality similar
im making file transfer (Server-Client) TCP i've already looked for same questions like this
I have a server, and Client that are working fine, they transfer file to
I am making simple one on server side & one on client side application
I'm making an application server client using tcp sockets in c# .. The application
i am making an application which first compresses a file and then transfer it.
How do I go about making a socket policy file server in C#. All

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.