Click here to Skip to main content
15,897,334 members
Articles / Programming Languages / C#

File Renamer Lite v1.2

Rate me:
Please Sign up or sign in to vote.
4.80/5 (7 votes)
20 Oct 2010CPOL2 min read 46K   1.4K   30  
A simplified file renamer
using System;
using System.Windows.Forms;
using System.Collections;

namespace File_Renamer
{
    public partial class frmConfirmation : Form
    {
        public frmConfirmation()
        {
            InitializeComponent();
        }

        private void btnAbort_Click(object sender, EventArgs e)
        {
            cData.Confirm = false;
            this.Close();
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            cData.Confirm = true;
            this.Close();
        }

        private void frmConfirmation_Load(object sender, EventArgs e)
        {
            int sz = (int)(listResults.Width * 0.5);
            listResults.View = View.Details;
            listResults.FullRowSelect = true;

            listResults.Columns.Add("After Rename", sz);
            listResults.Columns.Add("Before Rename", sz);

            for (int i=0; i< cData.FileList.Count; i++)
            {
                ListViewItem li = new ListViewItem();
                li.Text = cData.ChangeList[i].ToString();
                li.SubItems.Add(cData.FileList[i].ToString());
                listResults.Items.Add(li);
            }
        }

        private void frmConfirmation_Resize(object sender, EventArgs e)
        {
            panel1.Height = panel2.Top;
        }

        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (listResults.Items.Count > 0)
            {
                ArrayList list = new ArrayList();
                for (int i = 0; i < listResults.Items.Count; i++ )
                {
                    if (listResults.Items[i].Selected)
                    {
                        listResults.Items.RemoveAt(i);
                        cData.ChangeList.RemoveAt(i);
                        cData.FileList.RemoveAt(i);
                    }
                }
                /*int pos = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    pos = (int)list[i];
                    listResults.Items[pos].Remove();
                    cData.ChangeList.RemoveAt(pos);
                    cData.FileList.RemoveAt(pos);
                }*/
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Network Administrator vtdev.com
Canada Canada
Network and programming specialist. Started in C, and have learned about 14 languages since then. Cisco programmer, and lately writing a lot of C# and WPF code, (learning Java too). If I can dream it up, I can probably put it to code. My software company, (VTDev), is on the verge of releasing a couple of very cool things.. keep you posted.

Comments and Discussions