I have a move function which moves the files from one folder to another folder..
I am wondering how can i show the total numbers of files moved and moved filenames in a dialog box. or any idea..!!!!

Here the problem is Once i press Move all the files moving, if at all there are some duplicate files it pops shows error msg in my grid view.. rest files starts keeps moving. SO i need a method once all files are moved.. i need to show a dialog box with total number of files moved and filenames moved in a dialog box.. is that possible.. or any idea.. Please post it..

I really appriciate that..

My codes:

 private void button3_Click(object sender, EventArgs e)
    {
        update = false;
        this.Enabled = false;
        backgroundWorker2.RunWorkerAsync();
        move();
        backgroundWorker2.CancelAsync();
        System.Threading.Thread.Sleep(500);
        this.Enabled = true;
        update = true;
    }

  public void move()
    {
        update = false;
        string archieve_path = ini.ReadValue("Location", "Archive");
        string release_path = ini.ReadValue("Location", "Release");
        string draft_path = ini.ReadValue("Location", "Draft");
        for (int i = 0; i < dataGridView1.Rows.Count; i++)
        {
            if ((!String.IsNullOrEmpty(dataGridView1.Rows[i].Cells["Draft Path"].Value.ToString()) && String.IsNullOrEmpty(dataGridView1.Rows[i].Cells["Release Path"].Value.ToString())) &&
                (dataGridView1.Rows[i].Cells[0].Value != null && (bool)dataGridView1.Rows[i].Cells[0].Value))
            {

                string draftpath = dataGridView1.Rows[i].Cells["Draft Path"].Value.ToString();
                string relasepath = dataGridView1.Rows[i].Cells["Release Path"].Value.ToString();
                string archievepath = dataGridView1.Rows[i].Cells["Archive"].Value.ToString();
                string draftname = System.IO.Path.GetFileName(draftpath);

                if (relasepath != string.Empty && draftname.Equals(Path.GetFileName(relasepath), StringComparison.OrdinalIgnoreCase))
                {
                    dataGridView1.Rows[i].Cells["Error"].Value = "Duplicate in Release: " + draftname + "";
                    dataGridView1.Rows[i].Cells["Error"].Style = new DataGridViewCellStyle { ForeColor = Color.Red };
                    continue;
                }
                if (archievepath != string.Empty && draftname.Equals(Path.GetFileName(archievepath), StringComparison.OrdinalIgnoreCase))
                {
                    dataGridView1.Rows[i].Cells["Error"].Value = "Duplicate in Archive: " + draftname + "";
                    dataGridView1.Rows[i].Cells["Error"].Style = new DataGridViewCellStyle { ForeColor = Color.Red };
                    continue;
                }

                string newpath = System.IO.Path.Combine(release_path, draftname);

                System.IO.File.Move(draftpath, newpath);
                dataGridView1.Rows[i].Cells["Release Path"].Value = newpath;
                dataGridView1.Rows[i].Cells["Draft Path"].Value = string.Empty;
                dataGridView1.Rows[i].Cells[0].Value = false; //Checkbox
            }

            if ((!String.IsNullOrEmpty(dataGridView1.Rows[i].Cells["Draft Path"].Value.ToString())
                && !String.IsNullOrEmpty(dataGridView1.Rows[i].Cells["Release Path"].Value.ToString())) &&
                (dataGridView1.Rows[i].Cells[0].Value != null && (bool)dataGridView1.Rows[i].Cells[0].Value))
            {
                string draftPath = dataGridView1.Rows[i].Cells["Draft Path"].Value.ToString();
                string releasepath = dataGridView1.Rows[i].Cells["Release Path"].Value.ToString();
                string archievepath = dataGridView1.Rows[i].Cells["Archive"].Value.ToString();

                string draftname = System.IO.Path.GetFileName(draftPath);
                string archievename = System.IO.Path.GetFileName(archievepath);
                string releasename = System.IO.Path.GetFileName(releasepath);


                if (archievepath != string.Empty && draftname.Equals(Path.GetFileName(archievepath), StringComparison.OrdinalIgnoreCase))
                {
                    dataGridView1.Rows[i].Cells["Error"].Value = "Duplicate in Archive: " + draftname + "";
                    dataGridView1.Rows[i].Cells["Error"].Style = new DataGridViewCellStyle { ForeColor = Color.Red };
                    continue;
                }
                if (releasepath != string.Empty && draftname.Equals(Path.GetFileName(releasepath), StringComparison.OrdinalIgnoreCase))
                {
                    dataGridView1.Rows[i].Cells["Error"].Value = "Duplicate in Release: " + draftname + "";
                    dataGridView1.Rows[i].Cells["Error"].Style = new DataGridViewCellStyle { ForeColor = Color.Red };
                    continue;
                }

                if (archievepath != string.Empty && releasename.Equals(Path.GetFileName(archievepath), StringComparison.OrdinalIgnoreCase))
                {
                    dataGridView1.Rows[i].Cells["Error"].Value = "Duplicate in Archive: " + releasename + "";
                    dataGridView1.Rows[i].Cells["Error"].Style = new DataGridViewCellStyle { ForeColor = Color.Red };
                    continue;
                }
                string fName1 = System.IO.Path.GetFileNameWithoutExtension(draftPath);
                string fName2 = System.IO.Path.GetFileNameWithoutExtension(releasepath);
                string fName3 = System.IO.Path.GetFileNameWithoutExtension(archievepath);
                var f1 = GetValue(fName1.ToCharArray()[fName1.Length - 2]) * 16 + GetValue(fName1.ToCharArray()[fName1.Length - 1]);
                var f2 = GetValue(fName2.ToCharArray()[fName2.Length - 2]) * 16 + GetValue(fName2.ToCharArray()[fName2.Length - 1]);
                // var f3 = GetValue(fName3.ToCharArray()[fName3.Length - 2]) * 16 + GetValue(fName3.ToCharArray()[fName3.Length - 1]);

                if (f1 > f2)//till here
                {
                    //moves from realse to archieve
                    string newpath = System.IO.Path.Combine(archieve_path, releasename); //draft name + archieve
                    System.IO.File.Move(releasepath, newpath);
                    dataGridView1.Rows[i].Cells["Release Path"].Value = string.Empty;
                }

                if (f1 < f2)
                {
                    //moves draft to archieve
                    string newpath = System.IO.Path.Combine(archieve_path, draftname);
                    System.IO.File.Move(draftPath, newpath);
                    dataGridView1.Rows[i].Cells["Draft Path"].Value = string.Empty;
                    return;
                }

                string newpath1 = System.IO.Path.Combine(release_path, draftname);
                System.IO.File.Move(draftPath, newpath1);

                dataGridView1.Rows[i].Cells["Release Path"].Value = newpath1;
                dataGridView1.Rows[i].Cells["Draft Path"].Value = string.Empty;
                dataGridView1.Rows[i].Cells[0].Value = false; //Checkbox
            }
        }
        update = true;
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.