How to rename file using WinForms with C#

1 Answer

0 votes
namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // public static void Move (string (old)sourceFileName, (new)string destFileName);

            string oldfilename = "data.txt";

            if (File.Exists(oldfilename))
            {
                File.Move(oldfilename, "data.bin");
            }
        }
    }
}




/*
 * run:
 *
 * 
 * 
 */

 



answered Aug 22, 2023 by avibootz
...