ChangeExt

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RenameExt
{
    public partial class Form1 : Form
    {
        string[] files;
        
      
        public Form1()
        {
            InitializeComponent();
        }

        

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = folderBrowserDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                //
                // The user selected a folder and pressed the OK button.
                // We print the number of files found.
                //
              files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
    
              foreach (string file in files)
              {

                  richTextBox1.AppendText(file.ToString() + Environment.NewLine);
                  
              }

            }



        }

        private void button2_Click(object sender, EventArgs e)
        {
            foreach (string file in files)
            {
                File.Move(file, Path.ChangeExtension(file, textBox1.Text));

            }
            files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);

            richTextBox1.AppendText("You have changed following files "+Environment.NewLine);
            foreach (string file in files)
            {

                richTextBox1.AppendText(file.ToString() + Environment.NewLine);

            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            foreach (string file in files)
            {
               File.Move(file,file.Substring(0,file.Length-4));
             

            }

            files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);

            richTextBox1.AppendText("You have changed following files " + Environment.NewLine);
            foreach (string file in files)
            {

                richTextBox1.AppendText(file.ToString() + Environment.NewLine);

            }
        }

       
    }
}

 

About Lei

I am an IT specialist with over 10 year experience - years on Automation, on-Premise or Azure.

I am happy to develop however never want be a full time developer. Only do what I have to do. If it has to be PowerShell,HTML, PHP, CSS, C#, VBS or JS, front end or backend, so be it, doesn't matter!

Spent years with Windows, SCCM, SharePoint, SQL and Exchange servers. For last several years, I have been actively working under On Premise > Azure environment.

THERE IS NO WAY BACK!!!

Current Certificates:
    Microsoft® Certified-
  • -Enterprise Administrator
  • -Database Administrator
  • -SharePoint Administrator
  • -Administering and Deploying SCCM 2012
Red Hat Certified Technician
ITIL V3 Foundation - Practitioner

Working on Azure Certificates now and hopefully they can stop upgrading their questions one day! GIVE ME A BREAK!

Contact Lei

Name *
Email *
Comments *

Traffic since 10/08/2016

Today53
Yesterday83
This week677
This month1973
Total416333

Visitor Info

  • IP: 54.227.51.103
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

1
Online

2017-12-17

Login